diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 13ffc92020126b425e6eeca7262c7e9e311927c0..52ab96ceb4c9c6182fd1b961d279b1b7fc027354 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -2,7 +2,7 @@ variables:
TESTV_DIR: "/usr/local/testv"
LTV_DIR: "/usr/local/ltv"
EVS_BE_TEST_DIR_BASOP: "/usr/local/be_2_evs_basop"
- REFERENCE_BRANCH: "ivas-float-update"
+ REFERENCE_BRANCH: "static-sclaing-for-dmx-signals-to-ref"
BUILD_OUTPUT: "build_output.txt"
SCRIPTS_DIR: "/usr/local/scripts"
EXIT_CODE_NON_BE: 123
diff --git a/Workspace_msvc/lib_com.vcxproj b/Workspace_msvc/lib_com.vcxproj
index a18464d878a503ae2e6c14cdfd042800744d1248..24a67965e3e05a34cfd0906b74cea1a589f0789b 100644
--- a/Workspace_msvc/lib_com.vcxproj
+++ b/Workspace_msvc/lib_com.vcxproj
@@ -214,6 +214,7 @@
+
diff --git a/Workspace_msvc/lib_com.vcxproj.filters b/Workspace_msvc/lib_com.vcxproj.filters
index 4d60b3abd8ce011126bb7b89fe9a5bfac636a699..7aef315c4d2863aaf035f35c2af6d3821b824c85 100644
--- a/Workspace_msvc/lib_com.vcxproj.filters
+++ b/Workspace_msvc/lib_com.vcxproj.filters
@@ -426,11 +426,17 @@
+<<<<<<< HEAD
+=======
+
+ common_ivas_c
+
+>>>>>>> fix
diff --git a/Workspace_msvc/lib_rend.vcxproj b/Workspace_msvc/lib_rend.vcxproj
index fa11b23beb756bdfe1bbad4a3cf989ea5ed750bb..862e6eca09480e979c9710676ee35749869e4d62 100644
--- a/Workspace_msvc/lib_rend.vcxproj
+++ b/Workspace_msvc/lib_rend.vcxproj
@@ -148,7 +148,6 @@
-
diff --git a/Workspace_msvc/lib_rend.vcxproj.filters b/Workspace_msvc/lib_rend.vcxproj.filters
index 01f3dfb74b19aaa5bbfbce01fa14d68eaf0e5af8..0ab7898115348a8efacef6385ab64b2b2ff366e0 100644
--- a/Workspace_msvc/lib_rend.vcxproj.filters
+++ b/Workspace_msvc/lib_rend.vcxproj.filters
@@ -32,9 +32,6 @@
rend_c
-
- rend_c
-
rend_c
@@ -143,9 +140,6 @@
rend_h
-
- rend_h
-
diff --git a/lib_com/ivas_cnst.h b/lib_com/ivas_cnst.h
index eb529b37c50d98bec9f5aca76c181ae7871bccae..e7a4b13d18863196d4cd70d4e4c41eda54dbf3ee 100644
--- a/lib_com/ivas_cnst.h
+++ b/lib_com/ivas_cnst.h
@@ -1496,7 +1496,11 @@ typedef enum
#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 */
#define PARAM_MC_MAX_ILD_REF_CHANNELS 2 /* Maximum number of reference channels for a coded ILD */
-#define PARAM_MC_NUM_CONFIGS 14 /* Number of available Parametric MC configurations */
+#ifdef FIX_901_PARAMMC_DEAD_CODE
+#define PARAM_MC_NUM_CONFIGS 15 /* Number of available Parametric MC configurations */
+#else
+#define PARAM_MC_NUM_CONFIGS 15 /* Number of available Parametric MC configurations */
+#endif
#define PARAM_MC_MAX_BAND_LFE 1 /* Number of parameter bands for LFE coding */
#define PARAM_MC_SZ_ICC_MAP 11 /* Maximum number of transmitted ICCs per parameter band */
#define PARAM_MC_SZ_ILD_MAP 12 /* Maximum number of transmitted channel energies per band*/
@@ -1921,6 +1925,116 @@ typedef enum
} STEREO_DMX_EVS_PRC;
+/*----------------------------------------------------------------------------------*
+ * Static downmix scaling factors
+ *----------------------------------------------------------------------------------*/
+
+#ifdef NONBE_FIX_1165_STATIC_SCAL_MCMASA
+/* McMASA */
+/* 5.1 */
+#define ivas_mcmasa_dmx_scal_fac_CICP6_1tc_static ( 2.44948983f )
+#define ivas_mcmasa_dmx_scal_fac_CICP6_1tc_static_inv ( 1.0f / ivas_mcmasa_dmx_scal_fac_CICP6_1tc_static )
+
+/* 7.1 */
+#define ivas_mcmasa_dmx_scal_fac_CICP12_1tc_static ( 2.82842708f )
+#define ivas_mcmasa_dmx_scal_fac_CICP12_1tc_static_inv ( 1.0f / ivas_mcmasa_dmx_scal_fac_CICP12_1tc_static )
+
+/* 5.1+2 */
+#define ivas_mcmasa_dmx_scal_fac_CICP14_1tc_static ( 2.82842708f )
+#define ivas_mcmasa_dmx_scal_fac_CICP14_1tc_static_inv ( 1.0f / ivas_mcmasa_dmx_scal_fac_CICP14_1tc_static )
+
+/* 5.1+4 */
+#define ivas_mcmasa_dmx_scal_fac_CICP16_1tc_static ( 3.1622777f )
+#define ivas_mcmasa_dmx_scal_fac_CICP16_1tc_static_inv ( 1.0f / ivas_mcmasa_dmx_scal_fac_CICP16_1tc_static )
+
+#define ivas_mcmasa_dmx_scal_fac_CICP16_2tc_static ( 2.44948983f )
+#define ivas_mcmasa_dmx_scal_fac_CICP16_2tc_static_inv ( 1.0f / ivas_mcmasa_dmx_scal_fac_CICP16_2tc_static )
+
+#define ivas_mcmasa_dmx_scal_fac_CICP16_3tc_static ( 2.0f )
+#define ivas_mcmasa_dmx_scal_fac_CICP16_3tc_static_inv ( 1.0f / ivas_mcmasa_dmx_scal_fac_CICP16_3tc_static )
+
+/* 7.1+4 */
+#define ivas_mcmasa_dmx_scal_fac_CICP19_1tc_static ( 3.46410155f )
+#define ivas_mcmasa_dmx_scal_fac_CICP19_1tc_static_inv ( 1.0f / ivas_mcmasa_dmx_scal_fac_CICP19_1tc_static )
+
+#define ivas_mcmasa_dmx_scal_fac_CICP19_2tc_static ( 2.64575124f )
+#define ivas_mcmasa_dmx_scal_fac_CICP19_2tc_static_inv ( 1.0f / ivas_mcmasa_dmx_scal_fac_CICP19_2tc_static )
+
+#define ivas_mcmasa_dmx_scal_fac_CICP19_3tc_static ( 2.23606801f )
+#define ivas_mcmasa_dmx_scal_fac_CICP19_3tc_static_inv ( 1.0f / ivas_mcmasa_dmx_scal_fac_CICP19_3tc_static )
+
+/* Separated channel */
+#define ivas_mcmasa_dmx_scal_fac_sep_chan_static ( 2.0f )
+#define ivas_mcmasa_dmx_scal_fac_sep_chan_static_inv ( 1.0f / ivas_mcmasa_dmx_scal_fac_sep_chan_static )
+
+/* Fix version*/
+
+#define ivas_mcmasa_dmx_scal_fac_CICP6_1tc_static_FX_IN_Q29 ( 1315059840 )
+#define ivas_mcmasa_dmx_scal_fac_CICP6_1tc_static_inv_FX_IN_Q31 ( 876706496 )
+
+/* 7.1 */
+#define ivas_mcmasa_dmx_scal_fac_CICP12_1tc_static_FX_IN_Q29 ( 1518500224 )
+#define ivas_mcmasa_dmx_scal_fac_CICP12_1tc_static_inv_FX_IN_Q31 ( 759250112 )
+
+/* 5.1+2 */
+#define ivas_mcmasa_dmx_scal_fac_CICP14_1tc_static_FX_IN_Q29 ( 1518500224 )
+#define ivas_mcmasa_dmx_scal_fac_CICP14_1tc_static_inv_FX_IN_Q31 ( 759250112 )
+
+/* 5.1+4 */
+#define ivas_mcmasa_dmx_scal_fac_CICP16_1tc_static_FX_IN_Q29 ( 1697734912 )
+#define ivas_mcmasa_dmx_scal_fac_CICP16_1tc_static_inv_FX_IN_Q31 ( 679093952 )
+
+#define ivas_mcmasa_dmx_scal_fac_CICP16_2tc_static_FX_IN_Q29 ( 1315059840 )
+#define ivas_mcmasa_dmx_scal_fac_CICP16_2tc_static_inv_FX_IN_Q31 ( 876706496 )
+
+#define ivas_mcmasa_dmx_scal_fac_CICP16_3tc_static_FX_IN_Q29 ( 1073741824 )
+#define ivas_mcmasa_dmx_scal_fac_CICP16_3tc_static_inv_FX_IN_Q31 ( 1073741824 )
+
+/* 7.1+4 */
+#define ivas_mcmasa_dmx_scal_fac_CICP19_1tc_static_FX_IN_Q29 ( 1859775360 )
+#define ivas_mcmasa_dmx_scal_fac_CICP19_1tc_static_inv_FX_IN_Q31 ( 619925120 )
+
+#define ivas_mcmasa_dmx_scal_fac_CICP19_2tc_static_FX_IN_Q29 ( 1420426880 )
+#define ivas_mcmasa_dmx_scal_fac_CICP19_2tc_static_inv_FX_IN_Q31 ( 811672576 )
+
+#define ivas_mcmasa_dmx_scal_fac_CICP19_3tc_static_FX_IN_Q29 ( 1200479872 )
+#define ivas_mcmasa_dmx_scal_fac_CICP19_3tc_static_inv_FX_IN_Q31 ( 960383872 )
+
+/* Separated channel */
+#define ivas_mcmasa_dmx_scal_fac_sep_chan_static_FX_IN_Q29 ( 1073741824 )
+#define ivas_mcmasa_dmx_scal_fac_sep_chan_static_inv_FX_IN_Q31 ( 1073741824 )
+
+#endif
+
+#ifdef NONBE_FIX_1165_STATIC_SCAL_OMASA
+/* OMASA */
+/* Approximates that 2 channels sum coherently and rest are incoherent */
+#define ivas_omasa_dmx_scal_fac_2ch_static ( 2.0f )
+#define ivas_omasa_dmx_scal_fac_2ch_static_inv ( 1.0f / ivas_omasa_dmx_scal_fac_2ch_static )
+
+#define ivas_omasa_dmx_scal_fac_3ch_static ( 2.23606801f )
+#define ivas_omasa_dmx_scal_fac_3ch_static_inv ( 1.0f / ivas_omasa_dmx_scal_fac_3ch_static )
+
+#define ivas_omasa_dmx_scal_fac_4ch_static ( 2.44948983f )
+#define ivas_omasa_dmx_scal_fac_4ch_static_inv ( 1.0f / ivas_omasa_dmx_scal_fac_4ch_static )
+
+#define ivas_omasa_dmx_scal_fac_5ch_static ( 2.64575124f )
+#define ivas_omasa_dmx_scal_fac_5ch_static_inv ( 1.0f / ivas_omasa_dmx_scal_fac_5ch_static )
+
+
+#define ivas_omasa_dmx_scal_fac_2ch_static_FX_IN_Q29 ( 1073741824 )
+#define ivas_omasa_dmx_scal_fac_2ch_static_inv_FX_IN_Q31 ( 1073741824 )
+
+#define ivas_omasa_dmx_scal_fac_3ch_static_FX_IN_Q29 ( 1200479872 )
+#define ivas_omasa_dmx_scal_fac_3ch_static_inv_FX_IN_Q31 ( 960383872 )
+
+#define ivas_omasa_dmx_scal_fac_4ch_static_FX_IN_Q29 ( 1315059840 )
+#define ivas_omasa_dmx_scal_fac_4ch_static_inv_FX_IN_Q31 ( 876706496 )
+
+#define ivas_omasa_dmx_scal_fac_5ch_static_FX_IN_Q29 ( 1420426880 )
+#define ivas_omasa_dmx_scal_fac_5ch_static_inv_FX_IN_Q31 ( 811672576 )
+#endif
+
#endif
/* clang-format on */
/* IVAS_CNST_H */
diff --git a/lib_com/ivas_limiter.c b/lib_com/ivas_limiter.c
new file mode 100644
index 0000000000000000000000000000000000000000..ad019dbff689500e7d6626c8e1355a007cbe205f
--- /dev/null
+++ b/lib_com/ivas_limiter.c
@@ -0,0 +1,483 @@
+/******************************************************************************************************
+
+ (C) 2022-2024 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.
+
+*******************************************************************************************************/
+
+#include
+#include "options.h"
+#include
+#include "prot.h"
+#include "ivas_prot_fx.h"
+#include "ivas_rom_com.h"
+#include "wmc_auto.h"
+#include
+#include "ivas_prot_fx.h"
+
+
+#define ATTACK_CNST_48k ( 2106670080 ) // Q31
+#define ATTACK_CNST_32k ( 2086555136 ) // Q31
+#define ATTACK_CNST_16k ( 2027355264 ) // Q31
+#define ATTACK_CNST_8k ( 1913946752 ) // Q31
+
+
+/*-------------------------------------------------------------------*
+ * detect_strong_saturations()
+ *
+ * Detection of very strong saturations,
+ * usually happens as a consequence of a heavy corrupted bitstream
+ *-------------------------------------------------------------------*/
+
+/*! r: apply_strong_limiting flag */
+static Word16 detect_strong_saturations_fx(
+ const Word16 BER_detect, /* i : BER detect flag */
+ Word16 *strong_saturation_cnt, /* i/o: counter of strong saturations */
+ const Word32 max_val, /* i : maximum absolute value q_factor */
+ Word32 *frame_gain, /* i/o: frame gain value Q30 */
+ Word16 q_factor /* i : Q factor of the output samples */
+)
+{
+ Word16 apply_strong_limiting;
+ Word64 compare_max_value_Mul_3, compare_max_value_Mul_10;
+
+ apply_strong_limiting = 0;
+ move16();
+ compare_max_value_Mul_3 = W_shl( 98187, q_factor ); // 3 * IVAS_LIMITER_THRESHOLD : Q(q_factor)
+ compare_max_value_Mul_10 = W_shl( 327290, q_factor ); // 10 * IVAS_LIMITER_THRESHOLD : Q(q_factor)
+ test();
+ IF( BER_detect )
+ {
+ *strong_saturation_cnt = 50;
+ move16();
+ apply_strong_limiting = 1;
+ move16();
+ }
+ ELSE IF( GT_64( max_val, compare_max_value_Mul_3 ) && GT_16( *strong_saturation_cnt, 0 ) )
+ {
+ apply_strong_limiting = 1;
+ move16();
+ }
+ ELSE IF( GT_64( max_val, compare_max_value_Mul_10 ) )
+ {
+ *strong_saturation_cnt = add( *strong_saturation_cnt, 20 );
+ move16();
+ *strong_saturation_cnt = s_min( *strong_saturation_cnt, 50 );
+ move16();
+ apply_strong_limiting = 1;
+ move16();
+ }
+ ELSE
+ {
+ ( *strong_saturation_cnt )--;
+ *strong_saturation_cnt = s_max( *strong_saturation_cnt, 0 );
+ move16();
+ }
+
+ IF( apply_strong_limiting )
+ {
+ IF( LT_32( *frame_gain, 322122547 /* 0.3 in Q30 */ ) )
+ {
+ /* *frame_gain /= 3.0f; */
+ *frame_gain = Mpy_32_16_1( *frame_gain, 10923 /* 1/3 in Q15 */ ); /* Q30 */
+ move32();
+ }
+ ELSE
+ {
+ apply_strong_limiting = 0;
+ move16();
+ }
+ }
+
+ return apply_strong_limiting;
+}
+
+
+/*-------------------------------------------------------------------*
+ * ivas_limiter_open()
+ *
+ * Allocate and initialize limiter struct
+ *-------------------------------------------------------------------*/
+
+/*! r : limiter struct handle */
+ivas_error ivas_limiter_open_fx(
+ IVAS_LIMITER_HANDLE *hLimiter_out, /* o : limiter struct handle */
+ const Word16 max_num_channels, /* i : maximum number of I/O channels to be processed */
+ const Word32 sampling_rate /* i : sampling rate for processing */
+)
+{
+ Word16 i;
+ IVAS_LIMITER_HANDLE hLimiter;
+ Word32 attack_cnst_fx = 0;
+ move32();
+ test();
+ IF( max_num_channels <= 0 || sampling_rate <= 0 )
+ {
+ return ( IVAS_ERROR( IVAS_ERR_WRONG_PARAMS, "Wrong parameters for Limiter\n" ) );
+ }
+
+ IF( ( hLimiter = malloc( sizeof( IVAS_LIMITER ) ) ) == NULL )
+ {
+ return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Limiter handle\n" ) );
+ }
+
+ hLimiter->max_num_channels = max_num_channels;
+ move16();
+ hLimiter->num_channels = max_num_channels;
+ move16();
+
+ IF( ( hLimiter->channel_ptrs_fx = malloc( max_num_channels * sizeof( Word32 * ) ) ) == NULL )
+ {
+ return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Limiter handle\n" ) );
+ }
+ hLimiter->sampling_rate = sampling_rate;
+ move32();
+ hLimiter->gain_fx = ONE_IN_Q30;
+ move32();
+ hLimiter->release_heuristic_fx = 0; /* Q30 */
+ move32();
+ SWITCH( sampling_rate )
+ {
+ case 48000:
+ attack_cnst_fx = ATTACK_CNST_48k; /*Q31*/
+ move32();
+ BREAK;
+ case 32000:
+ attack_cnst_fx = ATTACK_CNST_32k; /*Q31*/
+ move32();
+ BREAK;
+ case 16000:
+ attack_cnst_fx = ATTACK_CNST_16k; /*Q31*/
+ move32();
+ BREAK;
+ case 8000:
+ attack_cnst_fx = ATTACK_CNST_8k; /*Q31*/
+ move32();
+ BREAK;
+ default:
+ assert( 0 );
+ }
+
+ hLimiter->attack_constant_fx = attack_cnst_fx; /* Q31 */
+ move32();
+ hLimiter->strong_saturation_count = 0;
+ move16();
+
+ FOR( i = 0; i < max_num_channels; ++i )
+ {
+ hLimiter->channel_ptrs_fx[i] = NULL;
+ }
+
+ *hLimiter_out = hLimiter;
+
+ return IVAS_ERR_OK;
+}
+
+
+/*-------------------------------------------------------------------*
+ * ivas_limiter_close()
+ *
+ * Deallocate limiter struct
+ *-------------------------------------------------------------------*/
+
+void ivas_limiter_close_fx(
+ IVAS_LIMITER_HANDLE *phLimiter /* i/o: pointer to limiter handle, can be NULL */
+)
+{
+ test();
+ IF( phLimiter == NULL || *phLimiter == NULL )
+ {
+ return;
+ }
+
+ free( ( *phLimiter )->channel_ptrs_fx );
+ free( *phLimiter );
+ *phLimiter = NULL;
+
+ return;
+}
+
+
+#ifdef NONBE_FIX_1165_APPLY_LIMITER_ON_ENCODER_DMX
+/*-------------------------------------------------------------------*
+ * ivas_limiter_apply()
+ *
+ * In-place saturation control for multichannel buffers with adaptive
+ * release time and special handling of bit errors
+ *-------------------------------------------------------------------*/
+
+void ivas_limiter_apply_fx(
+#else
+/*-------------------------------------------------------------------*
+ * ivas_limiter_dec()
+ *
+ * In-place saturation control for multichannel buffers with adaptive
+ * release time and special handling of bit errors
+ *-------------------------------------------------------------------*/
+void ivas_limiter_dec_fx(
+#endif
+ IVAS_LIMITER_HANDLE hLimiter, /* i/o: limiter struct handle */
+ Word32 *output[MAX_OUTPUT_CHANNELS], /* i/o: input/output buffer Q : q_factor */
+ const Word16 num_channels, /* i : number of channels to be processed */
+ const Word16 output_frame, /* i : number of samples per channel in the buffer */
+ const Word16 BER_detect, /* i : BER detect flag */
+ Word16 q_factor /* i : Q factor of the output samples */
+)
+{
+ Word16 c;
+ Word32 **channels;
+
+ /* return early if given bad parameters */
+ test();
+ test();
+ IF( hLimiter == NULL || output == NULL || output_frame <= 0 )
+ {
+ return;
+ }
+
+ /* Update number of channels and prepare pointers to the beginning of each of them */
+ assert( num_channels <= hLimiter->max_num_channels && "Number of channels must be lower than the maximum set during limiter initialization!" );
+ hLimiter->num_channels = s_min( num_channels, hLimiter->max_num_channels );
+ move16();
+ channels = hLimiter->channel_ptrs_fx;
+
+ FOR( c = 0; c < num_channels; ++c )
+ {
+ channels[c] = output[c]; /*q_factor*/
+ }
+ Word32 limiter_thresold = L_shl( IVAS_LIMITER_THRESHOLD, q_factor ); /*q_factor*/
+ limiter_process_fx( hLimiter, output_frame, limiter_thresold, BER_detect, &hLimiter->strong_saturation_count, q_factor );
+
+ return;
+}
+
+
+/*-------------------------------------------------------------------*
+ * limiter_process()
+ *
+ * hLimiter->channel_ptrs must be set before calling this function.
+ * Consider using a wrapper function like ivas_limiter_dec() instead
+ * of calling this directly.
+ *-------------------------------------------------------------------*/
+
+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 */
+ const Word32 threshold, /* i : signal amplitude above which limiting starts to be applied Q : q_factor */
+ const Word16 BER_detect, /* i : BER detect flag */
+ Word16 *strong_saturation_cnt, /* i/o: counter of strong saturations (can be NULL) */
+ Word16 q_factor /* i : Q factor of output samples */
+)
+{
+ Word16 i, c;
+ Word32 tmp, max_val;
+ Word32 *sample;
+ Word32 releaseHeuristic, releaseHeuristic_cnst, releaseHeuristic_cnst_2;
+ Word16 apply_limiting, apply_strong_limiting;
+ Word32 **output;
+ Word16 num_channels, scale, result;
+ Word32 release_constant, compare_value;
+ Word32 div32, gain, frame_gain, attack_constant;
+ Word16 idx;
+
+ /* return early if given nonsensical values */
+ test();
+ IF( hLimiter == NULL || output_frame <= 0 )
+ {
+ return;
+ }
+
+ apply_limiting = 1;
+ move16();
+ apply_strong_limiting = 0;
+ move16();
+
+ gain = hLimiter->gain_fx; /* Q30 */
+ move32();
+ output = hLimiter->channel_ptrs_fx;
+ num_channels = hLimiter->num_channels;
+ move16();
+ // sampling_rate = hLimiter->sampling_rate;
+ attack_constant = hLimiter->attack_constant_fx; /* Q31 */
+ move32();
+ /*-----------------------------------------------------------------*
+ * Find highest absolute peak sample value
+ *-----------------------------------------------------------------*/
+
+ max_val = 0;
+ move32();
+
+ FOR( i = 0; i < output_frame; i++ )
+ {
+ FOR( c = 0; c < num_channels; c++ )
+ {
+ tmp = L_abs( output[c][i] );
+ if ( GT_32( tmp, max_val ) )
+ {
+ max_val = tmp; /*q_factor*/
+ move32();
+ }
+ }
+ }
+
+ /* Release heuristic
+ *
+ * Value ranging from 0.f to 1.f. Increases on each frame that contains
+ * a sample with a value above threshold and decreases on each frame
+ * with all sample values below threshold.
+ *
+ * Values of 0 and 1 map to the shortest and longest release time, respectively.
+ *
+ * The goal of this heuristic is to avoid the "pumping" effect when only
+ * sharp transients exceed the threshold (use short release time), but also
+ * keep the gain curve smoother if the threshold is exceeded in many frames
+ * in a short span of time.
+ */
+ SWITCH( output_frame )
+ {
+ case 960:
+ case 640:
+ case 320:
+ case 160:
+ releaseHeuristic_cnst = 85899345; /*Q30*/
+ move32();
+ releaseHeuristic_cnst_2 = 21474836; /*Q30*/
+ move32();
+ BREAK;
+ default:
+ releaseHeuristic_cnst = 21474836; /*Q30*/
+ move32();
+ releaseHeuristic_cnst_2 = 5368709; /*Q30*/
+ move32();
+ BREAK;
+ }
+ releaseHeuristic = hLimiter->release_heuristic_fx; /* Q30 */
+ move32();
+
+ IF( GT_32( max_val, threshold ) )
+ {
+ frame_gain = L_shl( divide3232( threshold, max_val ), 15 ); // to Q30
+ releaseHeuristic = L_min( ONE_IN_Q30, L_add( releaseHeuristic, releaseHeuristic_cnst ) ); // releaseHeuristic_cnst is Q30 of ( 4.f * output_frame / sampling_rate )
+ // release_constant = powf( 0.01f, 1.0f / ( 0.005f * powf( 200.f, .08 ) * sampling_rate ) );
+ /* Unoptimized code for reference */
+ /* releaseHeuristic = min( 1.f, releaseHeuristic + ( (float) 2.f * output_frame / sampling_rate / adaptiveReleaseWindowLengthInSeconds ) );
+ * ^
+ * React faster when release time should be increased
+ */
+ }
+ ELSE
+ {
+ releaseHeuristic = L_max( 0, L_sub( releaseHeuristic, releaseHeuristic_cnst_2 ) ); // releaseHeuristic_cnst_2 is Q30 of output_frame / sampling_rate )
+ /* Unoptimized code for reference */
+ /*releaseHeuristic = max( 0.f, releaseHeuristic - ( (float) 0.5f * output_frame / sampling_rate / adaptiveReleaseWindowLengthInSeconds ) );
+ * ^
+ * React slower when release time should be decreased
+ */
+ /* No samples above threshold and gain from previous frame is already 1.f,
+ * therefore gain == 1.f for the entire frame. Skip processing. */
+ if ( GE_32( gain, ONE_IN_Q30 ) )
+ {
+ apply_limiting = 0;
+ move16();
+ }
+ /* No samples above threshold but gain from previous frame is not 1.f,
+ * transition to gain == 1.f */
+ frame_gain = ONE_IN_Q30;
+ move32();
+ }
+ /* Detection of very strong saturations */
+ IF( strong_saturation_cnt != NULL )
+ {
+ apply_strong_limiting = detect_strong_saturations_fx( BER_detect, strong_saturation_cnt, max_val, &frame_gain, q_factor );
+ }
+ compare_value = 107374182; // Q30 of 0.1f
+ move32();
+ /* Limit gain reduction to 20dB. Any peaks that require gain reduction
+ * higher than this are most likely due to bit errors during decoding */
+ test();
+ if ( LT_32( frame_gain, compare_value ) && !apply_strong_limiting )
+ {
+ frame_gain = compare_value; /*Q30*/
+ move32();
+ }
+
+ IF( apply_limiting )
+ {
+ /* 99% time constants of the gain curve
+ *
+ * The denominator of the second argument determines after how many
+ * samples the gain curve will reach 99% of its target value
+ */
+ div32 = 5368709; // Q30 of 0.005 which is the lowest values for (output_frame / sampling_rate)
+ move32();
+
+ result = BASOP_Util_Divide3232_Scale( releaseHeuristic, div32, &scale );
+ idx = extract_l( Mpy_32_32( hLimiter->sampling_rate, 134218 ) );
+ result = shr( result, sub( 15, scale ) );
+ release_constant = release_cnst_table[idx][result]; /* Q31 */
+ move32();
+ /* Unoptimized code for reference */
+ /* releaseTimeInSeconds = 0.005f * powf(200.f, releaseHeuristic); <-- Map heuristic value (0; 1) exponentially to range (0.005; 1)
+ * release_constant = powf( 0.01f, 1.0f / ( releaseTimeInSeconds * sampling_rate ) );
+ */
+
+ /*-----------------------------------------------------------------*
+ * Apply limiting
+ *-----------------------------------------------------------------*/
+
+ FOR( i = 0; i < output_frame; i++ )
+ {
+ /* Update gain */
+ IF( LT_32( frame_gain, gain ) )
+ {
+ gain = Madd_32_32( frame_gain, attack_constant, L_sub( gain, frame_gain ) ); /* Q30 */
+ }
+ ELSE
+ {
+ gain = Madd_32_32( frame_gain, release_constant, L_sub( gain, frame_gain ) ); /* Q30 */
+ }
+
+ FOR( c = 0; c < num_channels; c++ )
+ {
+ sample = &output[c][i];
+
+ /* Apply gain */
+ *sample = Mpy_32_32( L_shl_sat( *sample, 1 ), gain ); /* Q(q_factor) */
+ move32();
+ }
+ }
+ }
+
+ /* Save last gain and release heuristic values for next frame */
+ hLimiter->gain_fx = gain; /* Q30 */
+ move32();
+ hLimiter->release_heuristic_fx = releaseHeuristic; /* Q30 */
+ move32();
+
+ return;
+}
diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h
index 46eb5f12a6aae256f1dc4d5f98fa79375d42d06b..d49d26bf7fb2dd0ebfeee03204a9831928dcb7a0 100644
--- a/lib_com/ivas_prot.h
+++ b/lib_com/ivas_prot.h
@@ -4126,6 +4126,21 @@ ivas_error ivas_mcmasa_dec_reconfig(
Decoder_Struct *st_ivas /* i/o: IVAS decoder handle */
);
+#ifdef NONBE_FIX_1165_STATIC_SCAL_MCMASA
+void ivas_mcmasa_gain_umx(
+ Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */
+ float *data_f[], /* i/o: output signals */
+ const int16_t output_frame /* i : output frame length per channel */
+);
+
+#endif
+#ifdef NONBE_FIX_1165_STATIC_SCAL_OMASA
+void ivas_omasa_gain_umx(
+ Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */
+ float *data_f[], /* i/o: output signals */
+ const int16_t output_frame /* i : output frame length per channel */
+);
+#endif
void ivas_mcmasa_setNumTransportChannels(
int16_t* nchan_transport, /* o : Pointer to number of transport channels to be set */
int16_t* element_mode, /* o : Pointer to element mode to be set */
@@ -4491,4 +4506,36 @@ void ivas_fb_mixer_get_windowed_fr(
/*! r: number of spectral bands */
+#ifdef NONBE_FIX_1165_APPLY_LIMITER_ON_ENCODER_DMX
+/*----------------------------------------------------------------------------------*
+ * 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_apply
+(
+ 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 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) */
+);
+#endif
/* clang-format on */
diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h
index ecebf22dc7b5f75df4dd33c9a31aa81736311484..17da715eeb7addaad428dccc0d1fb713db4e7e4b 100644
--- a/lib_com/ivas_prot_fx.h
+++ b/lib_com/ivas_prot_fx.h
@@ -100,7 +100,32 @@ ivas_error ivas_masa_dec_reconfigure_fx(
UWord16 *nSamplesRendered, /* o : number of samples flushed from the previous frame (JBM) */
Word16 *data /* o : output synthesis signal */
);
-
+#ifdef NONBE_FIX_1165_APPLY_LIMITER_ON_ENCODER_DMX
+#ifdef IVAS_FLOAT_FIXED
+#ifdef NONBE_FIX_1165_APPLY_LIMITER_ON_ENCODER_DMX
+void ivas_limiter_apply_fx(
+#else
+void ivas_limiter_dec_fx(
+#endif
+ IVAS_LIMITER_HANDLE hLimiter, /* i/o: limiter struct handle */
+ Word32 *output[MAX_OUTPUT_CHANNELS], /* i/o: input/output buffer */
+ const Word16 num_channels, /* i : number of channels to be processed */
+ const Word16 output_frame, /* i : number of samples per channel in the buffer */
+ const Word16 BER_detect, /* i : BER detect flag */
+ Word16 q_factor /* i : Q factor of the output samples */
+);
+#endif
+#ifdef IVAS_FLOAT_FIXED
+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 */
+ const Word32 threshold, /* i : signal amplitude above which limiting starts to be applied */
+ const Word16 BER_detect, /* i : BER detect flag */
+ Word16 *strong_saturation_cnt, /* i/o: counter of strong saturations (can be NULL) */
+ Word16 q_factor /* i : Q factor of output samples */
+);
+#endif
+#endif
void reconstruct_ism_ratios_fx(
Word16 *ratio_ism_idx, /* i : index vector Q0 */
const Word16 nchan_ism, /* i : number of components/objects Q0 */
@@ -810,6 +835,22 @@ ivas_error ivas_cpe_dec_fx(
const Word16 nb_bits_metadata /* i : number of metadata bits */
);
+#ifdef NONBE_FIX_1165_STATIC_SCAL_MCMASA
+void ivas_mcmasa_gain_umx_fx(
+ Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */
+ Word32 *data_f[], /* i/o: output signals Qx*/
+ const Word16 output_frame /* i : output frame length per channel */
+);
+
+#endif
+#ifdef NONBE_FIX_1165_STATIC_SCAL_OMASA
+void ivas_omasa_gain_umx_fx(
+ Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */
+ Word32 *data_f[], /* i/o: output signals Qx*/
+ const Word16 output_frame /* i : output frame length per channel */
+);
+#endif
+
void ivas_post_proc_fx(
SCE_DEC_HANDLE hSCE, /* i/o: SCE decoder structure */
CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */
diff --git a/lib_com/ivas_rom_com.c b/lib_com/ivas_rom_com.c
index a86f2913c2aecf07b420bf450b9106eab8b7d9a4..56f24085265bca0599d27848e52ce16366d318df 100644
--- a/lib_com/ivas_rom_com.c
+++ b/lib_com/ivas_rom_com.c
@@ -1747,18 +1747,42 @@ const Word16 Param_MC_index[MAX_CICP_CHANNELS] =
};
+#ifdef NONBE_FIX_1165_STATIC_SCAL_PARAMMC
+#define ivas_param_mc_dmx_scal_fac_CICP6_2tc_static 4.f /* orig: (2.0f + 2.f * INV_SQRT2) */
+#define ivas_param_mc_dmx_scal_fac_CICP6_2tc_static_inv (1.f / ivas_param_mc_dmx_scal_fac_CICP6_2tc_static)
+
+#define ivas_param_mc_dmx_scal_fac_CICP6_2tc_static_FX_IN_Q29 ONE_IN_Q31 /* orig: (2.0f + 2.f * INV_SQRT2) */
+#define ivas_param_mc_dmx_scal_fac_CICP6_2tc_static_inv_FX_IN_Q31 (ONE_IN_Q29)
+#endif
+
const Word32 ivas_param_mc_dmx_fac_CICP6_2tc_fx[12] =
{
2147483647,0,1518500224,1518500224,2147483647,0, /*Lt*/
0,2147483647,1518500224,1518500224,0,2147483647 /*Rt*/
};
+#ifdef NONBE_FIX_1165_STATIC_SCAL_PARAMMC
+#define ivas_param_mc_dmx_scal_fac_CICP12_2tc_static 4.f /* orig: (3.0f + 2.f * INV_SQRT2) */
+#define ivas_param_mc_dmx_scal_fac_CICP12_2tc_static_inv (1.f / ivas_param_mc_dmx_scal_fac_CICP12_2tc_static)
+
+#define ivas_param_mc_dmx_scal_fac_CICP12_2tc_static_FX_IN_Q29 ONE_IN_Q31 /* orig: (3.0f + 2.f * INV_SQRT2) */
+#define ivas_param_mc_dmx_scal_fac_CICP12_2tc_static_inv_FX_IN_Q31 (ONE_IN_Q29)
+#endif
+
const Word32 ivas_param_mc_dmx_fac_CICP12_2tc_fx[16] =
{
2147483647,0,1518500224,1518500224,2147483647,0,2147483647,0, /*Lt*/
0,2147483647,1518500224,1518500224,0,2147483647,0,2147483647 /*Rt*/
};
+#ifdef NONBE_FIX_1165_STATIC_SCAL_PARAMMC
+#define ivas_param_mc_dmx_scal_fac_CICP12_3tc_static 4.f /* orig: (3.0f) */
+#define ivas_param_mc_dmx_scal_fac_CICP12_3tc_static_inv (1.f / ivas_param_mc_dmx_scal_fac_CICP12_3tc_static)
+
+#define ivas_param_mc_dmx_scal_fac_CICP12_3tc_static_FX_IN_Q29 ONE_IN_Q31 /* orig: (3.0f) */
+#define ivas_param_mc_dmx_scal_fac_CICP12_3tc_static_inv_FX_IN_Q31 (ONE_IN_Q29)
+#endif
+
const Word32 ivas_param_mc_dmx_fac_CICP12_3tc_fx[24] =
{
2147483647,0,0,0,2147483647,0,2147483647,0, /*Lt*/
@@ -1766,11 +1790,28 @@ const Word32 ivas_param_mc_dmx_fac_CICP12_3tc_fx[24] =
0,0,2147483647,2147483647,0,0,0,0 /*Ct*/
};
+#ifdef NONBE_FIX_1165_STATIC_SCAL_PARAMMC
+#define ivas_param_mc_dmx_scal_fac_CICP14_2tc_static 4.f /* orig: (3.0f + 2.f * INV_SQRT2) */
+#define ivas_param_mc_dmx_scal_fac_CICP14_2tc_static_inv (1.f / ivas_param_mc_dmx_scal_fac_CICP14_2tc_static)
+
+#define ivas_param_mc_dmx_scal_fac_CICP14_2tc_static_FX_IN_Q29 ONE_IN_Q31 /* orig: (3.0f + 2.f * INV_SQRT2) */
+#define ivas_param_mc_dmx_scal_fac_CICP14_2tc_static_inv_FX_IN_Q31 (ONE_IN_Q29)
+#endif
+
const Word32 ivas_param_mc_dmx_fac_CICP14_2tc_fx[16] =
{
2147483647,0,1518500224,1518500224,2147483647,0,2147483647,0, /*Lt*/
0,2147483647,1518500224,1518500224,0,2147483647,0,2147483647 /*Rt*/
};
+
+#ifdef NONBE_FIX_1165_STATIC_SCAL_PARAMMC
+#define ivas_param_mc_dmx_scal_fac_CICP14_3tc_static 4.f /* orig: (3.0f) */
+#define ivas_param_mc_dmx_scal_fac_CICP14_3tc_static_inv (1.f / ivas_param_mc_dmx_scal_fac_CICP14_3tc_static)
+
+#define ivas_param_mc_dmx_scal_fac_CICP14_3tc_static_FX_IN_Q29 ONE_IN_Q31 /* orig: (3.0f) */
+#define ivas_param_mc_dmx_scal_fac_CICP14_3tc_static_inv_FX_IN_Q31 (ONE_IN_Q29)
+#endif
+
const Word32 ivas_param_mc_dmx_fac_CICP14_3tc_fx[24] =
{
2147483647,0,0,0,2147483647,0,2147483647,0, /*Lt*/
@@ -1778,6 +1819,14 @@ const Word32 ivas_param_mc_dmx_fac_CICP14_3tc_fx[24] =
0,0,2147483647,2147483647,0,0,0,0 /*Ct*/
};
+#ifdef NONBE_FIX_1165_STATIC_SCAL_PARAMMC
+#define ivas_param_mc_dmx_scal_fac_CICP16_3tc_static (4.0f)
+#define ivas_param_mc_dmx_scal_fac_CICP16_3tc_static_inv (1.f / ivas_param_mc_dmx_scal_fac_CICP16_3tc_static)
+
+#define ivas_param_mc_dmx_scal_fac_CICP16_3tc_static_FX_IN_Q29 (ONE_IN_Q31)
+#define ivas_param_mc_dmx_scal_fac_CICP16_3tc_static_inv_FX_IN_Q31 ONE_IN_Q29
+#endif
+
const Word32 ivas_param_mc_dmx_fac_CICP16_3tc_fx[30] =
{
2147483647,0,0,0,2147483647,0,2147483647,0,2147483647,0, /*Lt*/
@@ -1785,6 +1834,14 @@ const Word32 ivas_param_mc_dmx_fac_CICP16_3tc_fx[30] =
0,0,2147483647,2147483647,0,0,0,0,0,0 /*Ct*/
};
+#ifdef NONBE_FIX_1165_STATIC_SCAL_PARAMMC
+#define ivas_param_mc_dmx_scal_fac_CICP19_3tc_static 4.f /* orig: (5.0f) */
+#define ivas_param_mc_dmx_scal_fac_CICP19_3tc_static_inv (1.f / ivas_param_mc_dmx_scal_fac_CICP19_3tc_static)
+
+#define ivas_param_mc_dmx_scal_fac_CICP19_3tc_static_FX_IN_Q29 ONE_IN_Q31 /* orig: (5.0f) */
+#define ivas_param_mc_dmx_scal_fac_CICP19_3tc_static_inv_FX_IN_Q31 ONE_IN_Q29
+#endif
+
const Word32 ivas_param_mc_dmx_fac_CICP19_3tc_fx[36] =
{
2147483647,0,0,0,2147483647,0,2147483647,0,2147483647,0,2147483647,0, /*Lt*/
@@ -2068,8 +2125,12 @@ const PARAM_MC_CONF ivas_param_mc_conf[PARAM_MC_NUM_CONFIGS] =
IVAS_48k,
&ivas_param_mc_ild_mapping_CICP6_2tc,
&ivas_param_mc_icc_mapping_CICP6_2tc,
+#ifdef NONBE_FIX_1165_STATIC_SCAL_PARAMMC
&ivas_param_mc_ild_fac_CICP6_2tc_fx[0],
- &ivas_param_mc_dmx_fac_CICP6_2tc_fx[0]
+ &ivas_param_mc_dmx_fac_CICP6_2tc_fx[0],
+ ivas_param_mc_dmx_scal_fac_CICP6_2tc_static_FX_IN_Q29,
+ ivas_param_mc_dmx_scal_fac_CICP6_2tc_static_inv_FX_IN_Q31
+#endif
},
/* CICP6 64000 */
{
@@ -2079,8 +2140,12 @@ const PARAM_MC_CONF ivas_param_mc_conf[PARAM_MC_NUM_CONFIGS] =
IVAS_64k,
&ivas_param_mc_ild_mapping_CICP6_2tc,
&ivas_param_mc_icc_mapping_CICP6_2tc,
- &ivas_param_mc_ild_fac_CICP6_2tc_fx[0],
- & ivas_param_mc_dmx_fac_CICP6_2tc_fx[0]
+#ifdef NONBE_FIX_1165_STATIC_SCAL_PARAMMC
+ &ivas_param_mc_ild_fac_CICP6_2tc_fx[0],
+ & ivas_param_mc_dmx_fac_CICP6_2tc_fx[0],
+ ivas_param_mc_dmx_scal_fac_CICP6_2tc_static_FX_IN_Q29,
+ ivas_param_mc_dmx_scal_fac_CICP6_2tc_static_inv_FX_IN_Q31
+#endif
},
/* CICP6 80000 */
{
@@ -2090,8 +2155,12 @@ const PARAM_MC_CONF ivas_param_mc_conf[PARAM_MC_NUM_CONFIGS] =
IVAS_80k,
&ivas_param_mc_ild_mapping_CICP6_2tc,
&ivas_param_mc_icc_mapping_CICP6_2tc,
+#ifdef NONBE_FIX_1165_STATIC_SCAL_PARAMMC
&ivas_param_mc_ild_fac_CICP6_2tc_fx[0],
- & ivas_param_mc_dmx_fac_CICP6_2tc_fx[0]
+ & ivas_param_mc_dmx_fac_CICP6_2tc_fx[0],
+ ivas_param_mc_dmx_scal_fac_CICP6_2tc_static_FX_IN_Q29,
+ ivas_param_mc_dmx_scal_fac_CICP6_2tc_static_inv_FX_IN_Q31
+#endif
},
/* CICP12 48000 */
{
@@ -2101,8 +2170,12 @@ const PARAM_MC_CONF ivas_param_mc_conf[PARAM_MC_NUM_CONFIGS] =
IVAS_48k,
&ivas_param_mc_ild_mapping_CICP12_2tc,
&ivas_param_mc_icc_mapping_CICP12_2tc,
+#ifdef NONBE_FIX_1165_STATIC_SCAL_PARAMMC
&ivas_param_mc_ild_fac_CICP12_2tc_fx[0],
- &ivas_param_mc_dmx_fac_CICP12_2tc_fx[0]
+ &ivas_param_mc_dmx_fac_CICP12_2tc_fx[0],
+ ivas_param_mc_dmx_scal_fac_CICP12_2tc_static_FX_IN_Q29,
+ ivas_param_mc_dmx_scal_fac_CICP12_2tc_static_inv_FX_IN_Q31
+#endif
},
/* CICP12 64000 */
{
@@ -2112,8 +2185,12 @@ const PARAM_MC_CONF ivas_param_mc_conf[PARAM_MC_NUM_CONFIGS] =
IVAS_64k,
&ivas_param_mc_ild_mapping_CICP12_2tc,
&ivas_param_mc_icc_mapping_CICP12_2tc,
+#ifdef NONBE_FIX_1165_STATIC_SCAL_PARAMMC
&ivas_param_mc_ild_fac_CICP12_2tc_fx[0],
- &ivas_param_mc_dmx_fac_CICP12_2tc_fx[0]
+ &ivas_param_mc_dmx_fac_CICP12_2tc_fx[0],
+ ivas_param_mc_dmx_scal_fac_CICP12_2tc_static_FX_IN_Q29,
+ ivas_param_mc_dmx_scal_fac_CICP12_2tc_static_inv_FX_IN_Q31
+#endif
},
/* CICP12 80000 */
{
@@ -2123,8 +2200,12 @@ const PARAM_MC_CONF ivas_param_mc_conf[PARAM_MC_NUM_CONFIGS] =
IVAS_80k,
&ivas_param_mc_ild_mapping_CICP12_2tc,
&ivas_param_mc_icc_mapping_CICP12_2tc,
+#ifdef NONBE_FIX_1165_STATIC_SCAL_PARAMMC
&ivas_param_mc_ild_fac_CICP12_2tc_fx[0],
&ivas_param_mc_dmx_fac_CICP12_2tc_fx[0],
+ ivas_param_mc_dmx_scal_fac_CICP12_2tc_static_FX_IN_Q29,
+ ivas_param_mc_dmx_scal_fac_CICP12_2tc_static_inv_FX_IN_Q31
+#endif
},
/* CICP12 96000 */
{
@@ -2134,8 +2215,12 @@ const PARAM_MC_CONF ivas_param_mc_conf[PARAM_MC_NUM_CONFIGS] =
IVAS_96k,
&ivas_param_mc_ild_mapping_CICP12_3tc,
&ivas_param_mc_icc_mapping_CICP12_3tc,
+#ifdef NONBE_FIX_1165_STATIC_SCAL_PARAMMC
&ivas_param_mc_ild_fac_CICP12_3tc_fx[0],
- &ivas_param_mc_dmx_fac_CICP12_3tc_fx[0]
+ &ivas_param_mc_dmx_fac_CICP12_3tc_fx[0],
+ ivas_param_mc_dmx_scal_fac_CICP12_3tc_static_FX_IN_Q29,
+ ivas_param_mc_dmx_scal_fac_CICP12_3tc_static_inv_FX_IN_Q31
+#endif
},
/* CICP14 48000 */
{
@@ -2145,8 +2230,12 @@ const PARAM_MC_CONF ivas_param_mc_conf[PARAM_MC_NUM_CONFIGS] =
IVAS_48k,
&ivas_param_mc_ild_mapping_CICP14_2tc,
&ivas_param_mc_icc_mapping_CICP14_2tc,
+#ifdef NONBE_FIX_1165_STATIC_SCAL_PARAMMC
&ivas_param_mc_ild_fac_CICP14_2tc_fx[0],
- &ivas_param_mc_dmx_fac_CICP14_2tc_fx[0]
+ &ivas_param_mc_dmx_fac_CICP14_2tc_fx[0],
+ ivas_param_mc_dmx_scal_fac_CICP14_2tc_static_FX_IN_Q29,
+ ivas_param_mc_dmx_scal_fac_CICP14_2tc_static_inv_FX_IN_Q31
+#endif
},
/* CICP14 64000 */
{
@@ -2156,8 +2245,12 @@ const PARAM_MC_CONF ivas_param_mc_conf[PARAM_MC_NUM_CONFIGS] =
IVAS_64k,
&ivas_param_mc_ild_mapping_CICP14_2tc,
&ivas_param_mc_icc_mapping_CICP14_2tc,
- &ivas_param_mc_ild_fac_CICP14_2tc_fx[0],
- &ivas_param_mc_dmx_fac_CICP14_2tc_fx[0]
+#ifdef NONBE_FIX_1165_STATIC_SCAL_PARAMMC
+ &ivas_param_mc_ild_fac_CICP14_2tc_fx[0],
+ &ivas_param_mc_dmx_fac_CICP14_2tc_fx[0],
+ ivas_param_mc_dmx_scal_fac_CICP14_2tc_static_FX_IN_Q29,
+ ivas_param_mc_dmx_scal_fac_CICP14_2tc_static_inv_FX_IN_Q31
+#endif
},
/* CICP14 80000 */
{
@@ -2167,8 +2260,12 @@ const PARAM_MC_CONF ivas_param_mc_conf[PARAM_MC_NUM_CONFIGS] =
IVAS_80k,
&ivas_param_mc_ild_mapping_CICP14_2tc,
&ivas_param_mc_icc_mapping_CICP14_2tc,
+#ifdef NONBE_FIX_1165_STATIC_SCAL_PARAMMC
&ivas_param_mc_ild_fac_CICP14_2tc_fx[0],
- &ivas_param_mc_dmx_fac_CICP14_2tc_fx[0]
+ & ivas_param_mc_dmx_fac_CICP14_2tc_fx[0],
+ ivas_param_mc_dmx_scal_fac_CICP14_2tc_static_FX_IN_Q29,
+ ivas_param_mc_dmx_scal_fac_CICP14_2tc_static_inv_FX_IN_Q31
+#endif
},
/* CICP14 96000 */
{
@@ -2178,8 +2275,12 @@ const PARAM_MC_CONF ivas_param_mc_conf[PARAM_MC_NUM_CONFIGS] =
IVAS_96k,
&ivas_param_mc_ild_mapping_CICP14_3tc,
&ivas_param_mc_icc_mapping_CICP14_3tc,
- &ivas_param_mc_ild_fac_CICP14_3tc_fx[0],
- &ivas_param_mc_dmx_fac_CICP14_3tc_fx[0]
+#ifdef NONBE_FIX_1165_STATIC_SCAL_PARAMMC
+ &ivas_param_mc_ild_fac_CICP14_3tc_fx[0],
+ & ivas_param_mc_dmx_fac_CICP14_3tc_fx[0],
+ ivas_param_mc_dmx_scal_fac_CICP14_3tc_static_FX_IN_Q29,
+ ivas_param_mc_dmx_scal_fac_CICP14_3tc_static_inv_FX_IN_Q31
+#endif
},
/* CICP16 96000 */
{
@@ -2189,8 +2290,12 @@ const PARAM_MC_CONF ivas_param_mc_conf[PARAM_MC_NUM_CONFIGS] =
IVAS_96k,
&ivas_param_mc_ild_mapping_CICP16_3tc,
&ivas_param_mc_icc_mapping_CICP16_3tc,
+#ifdef NONBE_FIX_1165_STATIC_SCAL_PARAMMC
&ivas_param_mc_ild_fac_CICP16_3tc_fx[0],
- &ivas_param_mc_dmx_fac_CICP16_3tc_fx[0]
+ &ivas_param_mc_dmx_fac_CICP16_3tc_fx[0],
+ ivas_param_mc_dmx_scal_fac_CICP16_3tc_static_FX_IN_Q29,
+ ivas_param_mc_dmx_scal_fac_CICP16_3tc_static_inv_FX_IN_Q31
+#endif
},
/* CICP16 128000 */
{
@@ -2199,9 +2304,13 @@ const PARAM_MC_CONF ivas_param_mc_conf[PARAM_MC_NUM_CONFIGS] =
3,
IVAS_128k,
&ivas_param_mc_ild_mapping_CICP16_3tc,
- &ivas_param_mc_icc_mapping_CICP16_3tc,
- &ivas_param_mc_ild_fac_CICP16_3tc_fx[0],
- &ivas_param_mc_dmx_fac_CICP16_3tc_fx[0]
+ &ivas_param_mc_icc_mapping_CICP16_3tc,
+#ifdef NONBE_FIX_1165_STATIC_SCAL_PARAMMC
+ &ivas_param_mc_ild_fac_CICP16_3tc_fx[0],
+ & ivas_param_mc_dmx_fac_CICP16_3tc_fx[0],
+ ivas_param_mc_dmx_scal_fac_CICP16_3tc_static_FX_IN_Q29,
+ ivas_param_mc_dmx_scal_fac_CICP16_3tc_static_inv_FX_IN_Q31
+#endif
},
/* CICP19 128000 */
{
@@ -2211,8 +2320,12 @@ const PARAM_MC_CONF ivas_param_mc_conf[PARAM_MC_NUM_CONFIGS] =
IVAS_128k,
&ivas_param_mc_ild_mapping_CICP19_3tc,
&ivas_param_mc_icc_mapping_CICP19_3tc,
+#ifdef NONBE_FIX_1165_STATIC_SCAL_PARAMMC
&ivas_param_mc_ild_fac_CICP19_3tc_fx[0],
- &ivas_param_mc_dmx_fac_CICP19_3tc_fx[0]
+ &ivas_param_mc_dmx_fac_CICP19_3tc_fx[0],
+ ivas_param_mc_dmx_scal_fac_CICP19_3tc_static_FX_IN_Q29,
+ ivas_param_mc_dmx_scal_fac_CICP19_3tc_static_inv_FX_IN_Q31
+#endif
}
};
@@ -3240,3 +3353,821 @@ const Word16 ivas_param_upmx_mx_qmap[33] =
{
0, 1, 2, 3, 4, 5, 6, 7, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 7, 6, 5, 4, 3, 2, 1, 0
};
+
+const Word32 release_cnst_table[4][201] = // Q31
+ {
+ {
+ 1913946752,
+ 1919716352,
+ 1925351680,
+ 1930855552,
+ 1936230784,
+ 1941479808,
+ 1946605312,
+ 1951609728,
+ 1956495744,
+ 1961265792,
+ 1965922304,
+ 1970467584,
+ 1974904320,
+ 1979234560,
+ 1983460736,
+ 1987585024,
+ 1991609856,
+ 1995537280,
+ 1999369344,
+ 2003108480,
+ 2006756480,
+ 2010315520,
+ 2013787520,
+ 2017174528,
+ 2020478464,
+ 2023701248,
+ 2026844672,
+ 2029910656,
+ 2032900992,
+ 2035817344,
+ 2038661376,
+ 2041435008,
+ 2044139648,
+ 2046777088,
+ 2049348864,
+ 2051856384,
+ 2054301440,
+ 2056685312,
+ 2059009536,
+ 2061275520,
+ 2063484672,
+ 2065638272,
+ 2067737856,
+ 2069784448,
+ 2071779584,
+ 2073724416,
+ 2075620096,
+ 2077467904,
+ 2079268992,
+ 2081024512,
+ 2082735488,
+ 2084403200,
+ 2086028416,
+ 2087612544,
+ 2089156352,
+ 2090660864,
+ 2092127104,
+ 2093555968,
+ 2094948480,
+ 2096305408,
+ 2097627776,
+ 2098916352,
+ 2100172032,
+ 2101395584,
+ 2102587776,
+ 2103749504,
+ 2104881408,
+ 2105984384,
+ 2107059072,
+ 2108106112,
+ 2109126400,
+ 2110120448,
+ 2111088896,
+ 2112032512,
+ 2112951808,
+ 2113847552,
+ 2114720128,
+ 2115570304,
+ 2116398592,
+ 2117205504,
+ 2117991552,
+ 2118757504,
+ 2119503616,
+ 2120230400,
+ 2120938496,
+ 2121628288,
+ 2122300288,
+ 2122954880,
+ 2123592576,
+ 2124213760,
+ 2124818944,
+ 2125408384,
+ 2125982592,
+ 2126541952,
+ 2127086848,
+ 2127617664,
+ 2128134656,
+ 2128638336,
+ 2129128832,
+ 2129606784,
+ 2130072192,
+ 2130525568,
+ 2130967296,
+ 2131397376,
+ 2131816448,
+ 2132224640,
+ 2132622080,
+ 2133009408,
+ 2133386496,
+ 2133753856,
+ 2134111744,
+ 2134460288,
+ 2134799744,
+ 2135130368,
+ 2135452416,
+ 2135766144,
+ 2136071680,
+ 2136369152,
+ 2136659072,
+ 2136941312,
+ 2137216256,
+ 2137484160,
+ 2137744896,
+ 2137998976,
+ 2138246400,
+ 2138487424,
+ 2138722176,
+ 2138950656,
+ 2139173376,
+ 2139390208,
+ 2139601408,
+ 2139807104,
+ 2140007424,
+ 2140202624,
+ 2140392576,
+ 2140577664,
+ 2140758016,
+ 2140933504,
+ 2141104512,
+ 2141271040,
+ 2141433216,
+ 2141591168,
+ 2141745024,
+ 2141894912,
+ 2142040832,
+ 2142182912,
+ 2142321408,
+ 2142456192,
+ 2142587392,
+ 2142715264,
+ 2142839808,
+ 2142961152,
+ 2143079296,
+ 2143194240,
+ 2143306240,
+ 2143415424,
+ 2143521664,
+ 2143625216,
+ 2143725952,
+ 2143824128,
+ 2143919744,
+ 2144012800,
+ 2144103424,
+ 2144191744,
+ 2144277760,
+ 2144361472,
+ 2144443136,
+ 2144522496,
+ 2144599936,
+ 2144675200,
+ 2144748544,
+ 2144820096,
+ 2144889600,
+ 2144957440,
+ 2145023488,
+ 2145087744,
+ 2145150336,
+ 2145211264,
+ 2145270656,
+ 2145328512,
+ 2145384832,
+ 2145439616,
+ 2145493120,
+ 2145545088,
+ 2145595776,
+ 2145645056,
+ 2145693184,
+ 2145739904,
+ 2145785472,
+ 2145829888,
+ 2145873152,
+ 2145915136,
+ 2145956224,
+ 2145996032,
+ 2146034944,
+ 2146072832,
+ 2146109696,
+ 2146145664,
+ 2146180608,
+ 2146214656,
+ 2146247808,
+ },
+ {
+ 2027355264,
+ 2030408704,
+ 2033386624,
+ 2036290944,
+ 2039123328,
+ 2041885440,
+ 2044578944,
+ 2047205376,
+ 2049766528,
+ 2052263680,
+ 2054698496,
+ 2057072384,
+ 2059387008,
+ 2061643520,
+ 2063843328,
+ 2065987968,
+ 2068078720,
+ 2070116864,
+ 2072103552,
+ 2074040192,
+ 2075927936,
+ 2077767936,
+ 2079561472,
+ 2081309568,
+ 2083013376,
+ 2084673920,
+ 2086292352,
+ 2087869696,
+ 2089406976,
+ 2090905216,
+ 2092365184,
+ 2093788032,
+ 2095174528,
+ 2096525824,
+ 2097842432,
+ 2099125632,
+ 2100375808,
+ 2101594240,
+ 2102781312,
+ 2103938048,
+ 2105065216,
+ 2106163456,
+ 2107233536,
+ 2108276096,
+ 2109292032,
+ 2110281728,
+ 2111246080,
+ 2112185728,
+ 2113101056,
+ 2113992960,
+ 2114861824,
+ 2115708288,
+ 2116532992,
+ 2117336448,
+ 2118119168,
+ 2118881792,
+ 2119624704,
+ 2120348416,
+ 2121053440,
+ 2121740288,
+ 2122409344,
+ 2123061120,
+ 2123696128,
+ 2124314624,
+ 2124917120,
+ 2125504128,
+ 2126075776,
+ 2126632832,
+ 2127175296,
+ 2127703808,
+ 2128218624,
+ 2128720000,
+ 2129208448,
+ 2129684352,
+ 2130147712,
+ 2130599168,
+ 2131038976,
+ 2131467264,
+ 2131884416,
+ 2132290816,
+ 2132686592,
+ 2133072256,
+ 2133447680,
+ 2133813504,
+ 2134169856,
+ 2134516864,
+ 2134854784,
+ 2135184000,
+ 2135504640,
+ 2135816960,
+ 2136121216,
+ 2136417536,
+ 2136706048,
+ 2136987136,
+ 2137260928,
+ 2137527552,
+ 2137787264,
+ 2138040192,
+ 2138286592,
+ 2138526464,
+ 2138760192,
+ 2138987776,
+ 2139209472,
+ 2139425408,
+ 2139635712,
+ 2139840512,
+ 2140039936,
+ 2140234240,
+ 2140423424,
+ 2140607744,
+ 2140787200,
+ 2140962048,
+ 2141132288,
+ 2141298048,
+ 2141459584,
+ 2141616896,
+ 2141769984,
+ 2141919232,
+ 2142064512,
+ 2142205952,
+ 2142343808,
+ 2142478080,
+ 2142608768,
+ 2142736128,
+ 2142860032,
+ 2142980864,
+ 2143098368,
+ 2143212928,
+ 2143324544,
+ 2143433088,
+ 2143538944,
+ 2143641984,
+ 2143742336,
+ 2143840000,
+ 2143935232,
+ 2144027904,
+ 2144118144,
+ 2144206080,
+ 2144291712,
+ 2144375168,
+ 2144456320,
+ 2144535424,
+ 2144612480,
+ 2144687488,
+ 2144760448,
+ 2144831616,
+ 2144900992,
+ 2144968448,
+ 2145034112,
+ 2145098112,
+ 2145160448,
+ 2145221248,
+ 2145280256,
+ 2145337856,
+ 2145393920,
+ 2145448576,
+ 2145501696,
+ 2145553536,
+ 2145603968,
+ 2145653120,
+ 2145700992,
+ 2145747456,
+ 2145792896,
+ 2145837056,
+ 2145880064,
+ 2145922048,
+ 2145962880,
+ 2146002560,
+ 2146041344,
+ 2146078976,
+ 2146115712,
+ 2146151424,
+ 2146186240,
+ 2146220160,
+ 2146253184,
+ 2146285312,
+ 2146316672,
+ 2146347136,
+ 2146376832,
+ 2146405760,
+ 2146433920,
+ 2146461440,
+ 2146488192,
+ 2146514176,
+ 2146539520,
+ 2146564224,
+ 2146588160,
+ 2146611584,
+ 2146634368,
+ 2146656640,
+ 2146678272,
+ 2146699264,
+ 2146719744,
+ 2146739712,
+ 2146759168,
+ 2146778112,
+ 2146796544,
+ 2146814464,
+ 2146832000,
+ 2146849024,
+ 2146865664,
+ },
+ {
+ 2086555136,
+ 2088125824,
+ 2089656576,
+ 2091148416,
+ 2092602240,
+ 2094018944,
+ 2095399680,
+ 2096745088,
+ 2098056192,
+ 2099333888,
+ 2100578816,
+ 2101792000,
+ 2102974080,
+ 2104125824,
+ 2105248128,
+ 2106341760,
+ 2107407232,
+ 2108445440,
+ 2109456896,
+ 2110442496,
+ 2111402624,
+ 2112338176,
+ 2113249664,
+ 2114137728,
+ 2115002880,
+ 2115845760,
+ 2116666880,
+ 2117466880,
+ 2118246272,
+ 2119005568,
+ 2119745280,
+ 2120465920,
+ 2121167872,
+ 2121851776,
+ 2122517888,
+ 2123166976,
+ 2123799168,
+ 2124414976,
+ 2125014912,
+ 2125599360,
+ 2126168704,
+ 2126723200,
+ 2127263360,
+ 2127789568,
+ 2128302208,
+ 2128801408,
+ 2129287808,
+ 2129761536,
+ 2130222976,
+ 2130672512,
+ 2131110272,
+ 2131536768,
+ 2131952128,
+ 2132356736,
+ 2132750848,
+ 2133134720,
+ 2133508736,
+ 2133872896,
+ 2134227584,
+ 2134573184,
+ 2134909696,
+ 2135237504,
+ 2135556736,
+ 2135867648,
+ 2136170624,
+ 2136465536,
+ 2136752896,
+ 2137032832,
+ 2137305344,
+ 2137570816,
+ 2137829376,
+ 2138081280,
+ 2138326528,
+ 2138565504,
+ 2138798080,
+ 2139024768,
+ 2139245440,
+ 2139460480,
+ 2139669888,
+ 2139873792,
+ 2140072320,
+ 2140265856,
+ 2140454144,
+ 2140637696,
+ 2140816384,
+ 2140990464,
+ 2141159936,
+ 2141325056,
+ 2141485824,
+ 2141642368,
+ 2141794944,
+ 2141943424,
+ 2142088064,
+ 2142228992,
+ 2142366208,
+ 2142499840,
+ 2142630016,
+ 2142756736,
+ 2142880128,
+ 2143000448,
+ 2143117440,
+ 2143231488,
+ 2143342592,
+ 2143450752,
+ 2143556096,
+ 2143658624,
+ 2143758592,
+ 2143855872,
+ 2143950592,
+ 2144043008,
+ 2144132864,
+ 2144220416,
+ 2144305664,
+ 2144388608,
+ 2144469504,
+ 2144548224,
+ 2144624896,
+ 2144699648,
+ 2144772352,
+ 2144843264,
+ 2144912256,
+ 2144979328,
+ 2145044864,
+ 2145108480,
+ 2145170560,
+ 2145231104,
+ 2145289856,
+ 2145347200,
+ 2145403008,
+ 2145457408,
+ 2145510400,
+ 2145561984,
+ 2145612160,
+ 2145661056,
+ 2145708672,
+ 2145755136,
+ 2145800192,
+ 2145844224,
+ 2145887104,
+ 2145928832,
+ 2145969408,
+ 2146008960,
+ 2146047616,
+ 2146085120,
+ 2146121600,
+ 2146157184,
+ 2146191872,
+ 2146225664,
+ 2146258560,
+ 2146290560,
+ 2146321792,
+ 2146352128,
+ 2146381696,
+ 2146410496,
+ 2146438528,
+ 2146465920,
+ 2146492416,
+ 2146518400,
+ 2146543616,
+ 2146568192,
+ 2146592128,
+ 2146615424,
+ 2146638080,
+ 2146660224,
+ 2146681728,
+ 2146702720,
+ 2146723072,
+ 2146743040,
+ 2146762368,
+ 2146781184,
+ 2146799616,
+ 2146817408,
+ 2146834816,
+ 2146851840,
+ 2146868352,
+ 2146884352,
+ 2146900096,
+ 2146915328,
+ 2146930176,
+ 2146944640,
+ 2146958720,
+ 2146972416,
+ 2146985856,
+ 2146998784,
+ 2147011456,
+ 2147023872,
+ 2147035904,
+ 2147047552,
+ 2147058944,
+ 2147070080,
+ 2147080832,
+ 2147091456,
+ 2147101696,
+ 2147111680,
+ 2147121408,
+ 2147130880,
+ 2147140096,
+ 2147149056,
+ 2147157760,
+ 2147166336,
+ 2147174656,
+ },
+ {
+ 2106670080,
+ 2107727232,
+ 2108757120,
+ 2109760640,
+ 2110738432,
+ 2111691008,
+ 2112619136,
+ 2113523328,
+ 2114404352,
+ 2115262592,
+ 2116098816,
+ 2116913408,
+ 2117707136,
+ 2118480256,
+ 2119233536,
+ 2119967360,
+ 2120682240,
+ 2121378688,
+ 2122057088,
+ 2122717952,
+ 2123361792,
+ 2123988992,
+ 2124599936,
+ 2125195136,
+ 2125774848,
+ 2126339584,
+ 2126889728,
+ 2127425536,
+ 2127947520,
+ 2128456064,
+ 2128951296,
+ 2129433856,
+ 2129903744,
+ 2130361600,
+ 2130807424,
+ 2131241728,
+ 2131664768,
+ 2132076928,
+ 2132478208,
+ 2132869248,
+ 2133250048,
+ 2133620992,
+ 2133982208,
+ 2134334080,
+ 2134676864,
+ 2135010688,
+ 2135335936,
+ 2135652608,
+ 2135961088,
+ 2136261504,
+ 2136554112,
+ 2136839168,
+ 2137116800,
+ 2137387136,
+ 2137650560,
+ 2137907072,
+ 2138156928,
+ 2138400256,
+ 2138637184,
+ 2138867968,
+ 2139092864,
+ 2139311744,
+ 2139524992,
+ 2139732736,
+ 2139934976,
+ 2140131968,
+ 2140323840,
+ 2140510720,
+ 2140692736,
+ 2140870016,
+ 2141042688,
+ 2141210752,
+ 2141374592,
+ 2141534080,
+ 2141689344,
+ 2141840640,
+ 2141987968,
+ 2142131456,
+ 2142271232,
+ 2142407424,
+ 2142539904,
+ 2142669056,
+ 2142794752,
+ 2142917248,
+ 2143036544,
+ 2143152640,
+ 2143265792,
+ 2143375872,
+ 2143483264,
+ 2143587712,
+ 2143689472,
+ 2143788544,
+ 2143885056,
+ 2143979136,
+ 2144070656,
+ 2144159872,
+ 2144246656,
+ 2144331264,
+ 2144413568,
+ 2144493824,
+ 2144571904,
+ 2144647936,
+ 2144722048,
+ 2144794240,
+ 2144864512,
+ 2144932864,
+ 2144999552,
+ 2145064448,
+ 2145127680,
+ 2145189248,
+ 2145249152,
+ 2145307520,
+ 2145364480,
+ 2145419776,
+ 2145473792,
+ 2145526272,
+ 2145577472,
+ 2145627264,
+ 2145675776,
+ 2145723008,
+ 2145768960,
+ 2145813760,
+ 2145857408,
+ 2145899904,
+ 2145941376,
+ 2145981696,
+ 2146020864,
+ 2146059136,
+ 2146096384,
+ 2146132608,
+ 2146167936,
+ 2146202368,
+ 2146235776,
+ 2146268416,
+ 2146300160,
+ 2146331136,
+ 2146361216,
+ 2146390528,
+ 2146419200,
+ 2146446976,
+ 2146474112,
+ 2146500480,
+ 2146526208,
+ 2146551168,
+ 2146575488,
+ 2146599296,
+ 2146622464,
+ 2146644864,
+ 2146666880,
+ 2146688128,
+ 2146708992,
+ 2146729216,
+ 2146748928,
+ 2146768128,
+ 2146786816,
+ 2146805120,
+ 2146822784,
+ 2146840064,
+ 2146856960,
+ 2146873344,
+ 2146889216,
+ 2146904832,
+ 2146919936,
+ 2146934656,
+ 2146948992,
+ 2146962944,
+ 2146976640,
+ 2146989824,
+ 2147002752,
+ 2147015296,
+ 2147027584,
+ 2147039488,
+ 2147051136,
+ 2147062400,
+ 2147073408,
+ 2147084160,
+ 2147094528,
+ 2147104768,
+ 2147114624,
+ 2147124352,
+ 2147133696,
+ 2147142912,
+ 2147151744,
+ 2147160448,
+ 2147168896,
+ 2147177088,
+ 2147185152,
+ 2147192960,
+ 2147200512,
+ 2147207936,
+ 2147215104,
+ 2147222144,
+ 2147229056,
+ 2147235712,
+ 2147242112,
+ 2147248384,
+ 2147254656,
+ 2147260544,
+ 2147266432,
+ 2147272064,
+ 2147277568,
+ },
+
+
+ };
diff --git a/lib_com/ivas_rom_com.h b/lib_com/ivas_rom_com.h
index 662dc81a9ba23ba6696e520d350c227b0139c1eb..7dc3fab0e532e6cf8ace66586412225d79906cb5 100644
--- a/lib_com/ivas_rom_com.h
+++ b/lib_com/ivas_rom_com.h
@@ -306,6 +306,8 @@ extern const Word16 ivas_fb_abs_bins_start_offset_12band_1ms[IVAS_NUM_SUPPORTED_
extern const Word16 ivas_num_active_bands[FB - WB + 1];
+extern const Word32 release_cnst_table[4][201]; // Q31
+
/*------------------------------------------------------------------------------------------*
* SNS MSVQ codebooks and means
*------------------------------------------------------------------------------------------*/
diff --git a/lib_com/ivas_stat_com.h b/lib_com/ivas_stat_com.h
index 090db04dbb413f44c2491d822da03799d7a990f9..e285be9f22346a948b2409ef285a5a8b3a8de963 100644
--- a/lib_com/ivas_stat_com.h
+++ b/lib_com/ivas_stat_com.h
@@ -572,7 +572,10 @@ typedef struct ivas_param_mc_conf_struct /* structure for ROM Table */
const PARAM_MC_ICC_MAPPING *icc_mapping_conf;
const Word16 *ild_factors_fx;
const Word32 *dmx_fac_fx; /* Q31 */
-
+#ifdef NONBE_FIX_1165_STATIC_SCAL_PARAMMC
+ Word32 static_dmx_fac_fx;
+ Word32 static_dmx_fac_inv_fx;
+#endif
} PARAM_MC_CONF;
typedef struct ivas_parametric_mc_metadata_value_coding_info_struct
@@ -794,4 +797,27 @@ typedef struct
Word16 hoardia_ratio2; /* Modified ratio index2 (hordiac_flag is 1) */
} Masa_Diffuseness_Ratios;
+
+#ifdef NONBE_FIX_1165_APPLY_LIMITER_ON_ENCODER_DMX
+/*----------------------------------------------------------------------------------*
+ * Limiter structure
+ *----------------------------------------------------------------------------------*/
+
+typedef struct
+{
+#ifdef DEBUGGING
+ int32_t cnt_frames_limited; /* counter of frames in which the limiter is applied */
+#endif
+ Word16 max_num_channels;
+ Word16 num_channels;
+ Word32 **channel_ptrs_fx;
+ Word32 sampling_rate;
+ Word32 gain_fx; /* Q30 */
+ Word32 release_heuristic_fx; /* Q30 */
+ Word32 attack_constant_fx; /* Q31 */
+ Word16 strong_saturation_count;
+} IVAS_LIMITER, *IVAS_LIMITER_HANDLE;
+
+#endif
+
#endif /* IVAS_STAT_COM */
diff --git a/lib_com/low_rate_band_att_fx.c b/lib_com/low_rate_band_att_fx.c
index d70da04dd0371357f667cb1d6f95bbd544819f7f..be06b8b0184b1d3cb7730c21276e3827b4915465 100644
--- a/lib_com/low_rate_band_att_fx.c
+++ b/lib_com/low_rate_band_att_fx.c
@@ -74,8 +74,17 @@ void ivas_fine_gain_pred_fx(
exp = norm_l( xx );
L_tmp = L_shl( xx, exp ); /*2*(15-shift)+exp */
exp = sub( 31, add( exp, sub( 30, shl( shift, 1 ) ) ) );
- L_tmp = Isqrt_lc( L_tmp, &exp ); /*31 - exp */
+ L_tmp = Isqrt_lc( L_tmp, &exp ); /*31 - exp */
+#ifndef FIX_ISSUE_987
Mpy_32_16_ss( L_tmp, ivas_fine_gain_pred_sqrt_bw[bw_idx], &L_tmp, &lsb ); /*31-exp+11-15=27-exp */
+#else
+ Word16 norm = norm_s( bw );
+ Word16 tmp1, tmp_exp = sub( 15, norm );
+ tmp1 = Sqrt16( shl( bw, norm ), &tmp_exp );
+ tmp1 = shr( tmp1, sub( sub( 15, tmp_exp ), Q11 ) );
+ Mpy_32_16_ss( L_tmp, tmp1, &L_tmp, &lsb ); /*31-exp+11-15=27-exp */
+#endif
+
#ifdef BASOP_NOGLOB
gp = round_fx_o( L_shl_o( L_tmp, add( 1, exp ), &Overflow ), &Overflow ); /*27-exp+1+exp-16=12 */
#else
diff --git a/lib_com/options.h b/lib_com/options.h
index cacefdab4fdb59427afcd30a35fccb3cd3bb7165..0283c66e1216599af458f069f1e126f4d8d31845 100644
--- a/lib_com/options.h
+++ b/lib_com/options.h
@@ -50,7 +50,8 @@
#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 DBG_WAV_WRITER*/ /* Enable dbgwrite_wav() function for generating ".wav" files */
+/*#define DBG_WAV_WRITER*/ /* enable dbgwrite_wav() function for generating ".wav" files */
+/*#define DISABLE_LIMITER_IN_DECODER*/ /* disable the limiter */
#endif
#define SUPPORT_JBM_TRACEFILE /* Support for JBM tracefile, which is needed for 3GPP objective/subjective testing, but not relevant for real-world implementations */
@@ -79,11 +80,88 @@
#define SIMPLIFY_CODE_BE // Simplify synthesis loop
#define CR_2109_to_2112_cd0_ce0 /* This is related to the CRs include in the 26.444 package of 21-12. Concerns lead_deindexing and */
#define FIX_QMETADATA_PENALTY /* Nokia: transform penalty calculation in qmetadata into integer operations */
+
#define FIX_1013_CRASH_HQ_CORE_DEC /* Ittiam: Saturation added on the lines of EVS */
#define NONE_BE_FIX_BASOP_1044_OSBA_PRERENDER_MIX_GAINS /* DLB: adjust prerendering and mixing gain in OSBA encoder. This is fix to float codes*/
#define NONBE_1233_HQ_CLASSIFIER_DIV_BY_ZERO /* Eri: issue 1233: Address possible division by zero in hf_spectrum_sparseness() */
#define FIX_ISSUE_1062_AND_1068_TON_ENE_EST_FX
+#define FIX_ISSUE_987
#define FIX_1054_IF_ELSE_CMPLX /* VA: Fix 1054 incorrect counting of complexity when ELSE-IF sequence is encoutered in two functions */
#define FIX_1052_COPY_CMPLX_DISCREPANCY /* VA: modify IF-ELSE statements used in Copy*() functions to avoid dependency on x[] and y[] in RAM */
#define FIX_1049_SHR_RO_COMPLEXITY /* VA: fix for issue 1049: incorrect counting of complexity in the shr_ro() function */
+#define NONBE_MDCT_ST_DTX_SKIP_DEWHITENING_OF_NOISE_SHAPES_ON_SID_FRAMES /* FhG: issue 1133: skip de-whitening of bg noise shape after frameloss period if the first good frame is an SID */
+#define NONBE_MDCT_ST_PLC_DO_NOT_SCALE_OLD_OUT_IF_FIRST_GOOD_IS_SID /* FhG: issue 1133: in TCX PLC, don't scale hHQ_core->old_out after applying fade to noise in burst frame error */
+#define NON_BE_FIX_BASOP_819_THRESHOLD_MASA2TOTAL
+#define FIX_903_ZERO_OUT_IMDCT_BUFFERS_FOR_MCT_IGNORE /* FhG: zero out all relevant imdct buffers in MCT decoding of channels with mct_chan_mode == MCT_CHAN_MODE_IGNORE */
+
+/* ##################### End NON-BE switches ########################### */
+#define FIX_740_HQ_CORE_OVA // Proposed fix to solve overlap and add issue for HQ_CORE
+#define FIX_746 // proposed fix to solve low bit-rate frame boundaries issues
+#define FIX_SATURATION_725 // Propose fix for saturation in AVQ
+#define FIX_737_HQ_ACELP_SWITCH_SCALING_ERROR /* Eri: Proposed fix for issue 737: scaling error in excitation memory after HQ->ACELP switch */
+#define FIX_736_BWE_SECT_C // Solves an issue where the BWE was disappearing, problem related to wrong scaling in ic-BWE
+#define FIX_734_MISSING_SUBFR_LOW_RATE_ACELP
+#define FIX_747_TDBWE_ENERGY_BURST
+#define FIX_770_DISCONTINUITIES_SW_TCX2ACELP // Fix discontinuities when switching from TCX to ACELP
+#define FIX_680_CNG_FRAME_BOUNDARIES_ISSUE /* Step was right shift by 2, which made the OVA wrong */
+#define NONBE_FIX_1069_SVD_TUNING /* FhG: issue 1069: tune SVD constants */
+#define FIX_778_STEREO_BRATE_SWITCHING
+#define FIX_774_ENERGY_BURST /* Fix 0 bit BWE */
+#define FIX_729_MISSING_RESCALING
+#define FIX_798_LSF_SECONDARY_CH_MISSING_CODE /* Adding the missing code to properly render the secondary channel of TD stereo*/
+#define FIX_798_WRONG_CPY_OF_PITCH /* The copy of the pitch from primary to secondary channel was wrong AND safety check was really wrong */
+#define FIX_800_PROPOSAL_HB_LPC_COEFFICIENT /* Proposal to fix wrong shape of TDBWE, #800 */
+
+#define FIX_802__NON_BE_DECODING /* Fix possible difference float and fixed point when computing the GSC bit allocation */
+#define FIX_802_1137_1137_GSC_IVAS_FXFLT_DECODING /* VA: ISSUES 802 and 1137 Made sure that float and fixed point GCS bit allocation is the same during IVAS modes */
+#define FIX_810_PREVENT_UNECESSARY_SAT_IN_TC /* VA : Prevent an unnecessary saturation that can happen in TC, have a minimal impact on most cases. Significant improvement for the last segment of LTV when TC is triggered */
+#define FIX_826_PRECISION_LOST_AND_COMPL /* VA : Fix lost of precision that leads to unnecessary high noise floor and to some framing artifacts */
+#ifdef FIX_826_PRECISION_LOST_AND_COMPL
+#define FIX_833_CORRECTION_to_826 /* VA : fix indexing error introduced in 826 */
+#endif
+#define NONE_BE_FIX_816_LFE_PLC_FLOAT /* DLB: issue 816: reduce required precision to float for LFE-PLC*/
+#define FIX_844_Q_SYN_INIT /* VA : proposed fix to 844, initializing q_old_synth when switching to MDCT*/
+#define FIX_839_FB_CONTENT_SOMETIME_MISSING /* VA : Fix scaling error for FB TB BWE */
+#define FIX_846_TILT_BWE /* VA : Proposed fix to 846, to solve saturation */
+#define FIX_843_LOW_RATE_BWE /* VA : Proposed fix to 843 to solve mid band noise */
+#define FIX851_RANGE_DEC_PRECISION /* VA : 851 Proposed fix to keep precision during UL_div*/
+#define FX_834_OVFL_JBM_CROSSCORR /* FhG: Proposed fix to 834, allow overflows in calculation */
+
+
+#define FIX_854_HILBERT_SCALING /* VA: reduce lost of precision due to unnecessary scaling, reduce a lot the 2 kHz tone */
+#define FIX_856_EXTRACT_L /* VA: Fix undesirable wrap-around */
+#define FIX_835_PARAMMC_BUFFER_VALUES /* FhG: issue 835: wide range of buffer values for cx in ParamMC */
+
+#define FIX_860_FER_CRASH /* VA: fix crash issues caused by saturation within shl */
+#define FIX_961_CRASH_DIV_L /* VA: fix to potential crash in div_l when index is <= 0 */
+
+#define FIX_869_WRONG_UVGAIN_STEP /* VA: Fix wrong decoding of uv gain quantizer for td-stereo*/
+
+#define FIX_871_REMOVE_UNNECESSARY_CONDITION /* VA: remove a condition that is not needed and prevented correct frame classification of the secondary channel of the TD stereo */
+
+#define FIX_874_INCREASE_IPD_PRECISION /*VA : Fix issue 874 by increasing ITD precision already when decoding index */
+#define FIX_874_INCREASE_IPD_PRECISION_A /*VA : Fix a possible issue where 2*PI should be used instead of PI (to be confirmed) */
+#define FIX_875_SATURATION_DURING_ROUNDING /* VA: fix a possible saturation when rounding */
+#define FIX_882_LOW_LEVEL_DISCONTINUITIES /* VA: Fix 882, discontinuities for low level signal by adding a scaling function that uses rounding, this function is more complex than normal one, has to be used only when necessary*/
+#define FIX_879_DIFF_CONCEAL_PATH /* FhG: Fix for issue 879 and different concelalment paths that led to crash */
+#define FIX_907_MEM_UPDATE_ISSUE /* VA: fix for 907, multiples issues surrounding mem_syn_r and update of mem_syn2 when FS is changing */
+#define FIX_918_WRONG_SCALING_ON_MODE_SWITCHING /* VA: Fix wrong scaling of secondary channel when switching from stereo DFT to TD */
+#define FIX_924_IGF_ROUNDFX_SAT
+#define FIX_930_JBM_BUFSIZE_MULT /* FhG: Fix 930, Word16 too small for apa_buffer_size */
+#define NONBE_FIX_943_PORT_1208_DFT_STEREO_PLC_BURST /* Ericsson: BASOP Issue 943, Float Issue 1208, fix for overflow of sample offset counter for burst error in DFT Stereo PLC. */
+#define FIX_853_DECODE_MASA_ISM_AZIMUTH_PREC /* Nokia: Fixes ivas_decode_masaism_metadata decision logic change due to precision difference; needs corresponding fix in floating point */
+#define FIX_953_WRONG_ENERGY_RATIO_MASA_EXT /* Nok: Fix 953 wrong energy ratio value after shift and cast to Word8 */
+#define FIX_982_WRONG_DECODED_ENERGY_RATIO /* Nokia: Fix 982 wrong energy in EXT mode and in second direction when present */
+#define FIX_999_WRONG_ISM_EXTENDED_METADATA /* VA: fix 999: fix ISM extended metadata decoding */
+/* ---- group of fixes for the static scaling of downmixes (WIP) ---- */
+#define NONBE_FIX_1165_STATIC_SCAL_MCMASA /* Nok: add static scaling to McMASA DMX */
+#define NONBE_FIX_1165_STATIC_SCAL_OMASA /* Nok: add static scaling to OMASA DMX */
+#define NONBE_FIX_1165_STATIC_SCAL_OSBA_PREREND /* FhG: static scaling factor for pre-rendered OSBA modes */
+
+#define NONBE_FIX_1165_STATIC_SCAL_PARAMMC /* FhG: add static scaling to ParamMC DMX */
+#define NONBE_FIX_1165_APPLY_LIMITER_ON_ENCODER_DMX /* FhG: apply the limiter before the core encoder for formats with downmixing where the signal could exceed the 16-bit value range */
+/* ################## End DEVELOPMENT switches ######################### */
+
+/* clang-format on */
+#define NONBE_FIX_1010_STEREO_CNG_DIV_BY_ZERO
#endif
diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h
index 40086183d77af30f3b65cee59d3787d003c40497..adfeed77cf1bbd838486822bd6fad11cf776c03c 100644
--- a/lib_com/prot_fx.h
+++ b/lib_com/prot_fx.h
@@ -2727,6 +2727,12 @@ void time_envelop_shaping_fx(
const Word16 L, /* i : frame length */
Word16 *Q_synth );
+void time_envelop_shaping_ivas_fx(
+ Word16 werr[], /* i/o: SHB synthesis Q_synth*/
+ Word32 SWB_tenv[], /* i/o: frequency envelope Q15*/
+ const Word16 L, /* i : frame length */
+ Word16 *Q_synth );
+
void time_reduce_pre_echo_fx(
const Word16 *synth, /* i : ACELP core synthesis Q_syn*/
Word16 *error, /* i/o: SHB BWE synthesis Q0*/
diff --git a/lib_com/swb_bwe_com_fx.c b/lib_com/swb_bwe_com_fx.c
index bd22e7e4259ec48ffc7a2626da5143c2fec263bc..873a7093eb5854f60af59e8863be738da3f33328 100644
--- a/lib_com/swb_bwe_com_fx.c
+++ b/lib_com/swb_bwe_com_fx.c
@@ -2202,6 +2202,97 @@ void time_envelop_shaping_fx(
L_tmp = Mult_32_16( SWB_tenv[i], tmp_ener ); /*Q(29-exp) */
tmp = round_fx( L_tmp ); /*Q(13-exp) */
+ FOR( j = 0; j < L / 4; j++ )
+ {
+#ifdef BASOP_NOGLOB
+ *pit = round_fx_sat( L_shl_sat( L_mult( tmp, *pit ), sub( exp, 1 ) ) ); /*Q(13-exp+1)->Q(14-exp)->Qsyn-3 */
+#else
+ *pit = round_fx( L_shl( L_mult( tmp, *pit ), sub( exp, 1 ) ) ); /*Q(13-exp+1)->Q(14-exp)->Qsyn-3 */
+#endif
+ move16();
+ pit++;
+ }
+ }
+ }
+
+ return;
+}
+
+void time_envelop_shaping_ivas_fx(
+ Word16 werr[], /* i/o: SHB synthesis Q_synth*/
+ Word32 SWB_tenv[], /* i/o: frequency envelope Q15*/
+ const Word16 L, /* i : frame length */
+ Word16 *Q_synth )
+{
+ Word16 *pit;
+ Word32 Energy;
+ Word16 i, j;
+ Word16 tmp_ener, Energy_16;
+ Word64 Energy_64;
+ Word16 exp_L, exp, frac, tmp, inv_L, w_tmp, Energy_Q;
+ Word32 L_tmp;
+
+ pit = werr;
+ exp_L = norm_s( L );
+ inv_L = div_s( shl( 1, sub( 14, exp_L ) ), L ); /*Q(29-exp_L) */
+ FOR( i = 0; i < SWB_TENV; i++ )
+ {
+ Energy_64 = L_deposit_l( 0 );
+ FOR( j = 0; j < L / 4; j++ )
+ {
+ Energy_64 = W_mac0_16_16( Energy_64, *pit, *pit ); /*(2*Q_synth) */
+ pit++;
+ }
+ w_tmp = W_norm( Energy_64 );
+ Energy_64 = W_shl( Energy_64, w_tmp );
+ Energy = W_extract_h( Energy_64 ); /*2*Q_synth + w_tmp -32*/
+ Energy_Q = sub( add( shl( ( *Q_synth ), 1 ), w_tmp ), 32 );
+ Energy = Mult_32_16( Energy, inv_L ); /*Q(29-exp_L-15) -> Q(-exp_L+14+2*Q_synth+w_tmp-32) */
+ Energy_16 = 0;
+ move16();
+ /*exp = 31-(-exp_L+14 +(2*(*Q_synth)+w_tmp-32)); */
+ exp = sub( 17, sub( Energy_Q, exp_L ) );
+
+ IF( Energy != 0 )
+ {
+ exp = norm_l( Energy );
+ frac = extract_h( L_shl( Energy, exp ) );
+ /*exp = sub(exp, 30-(-exp_L+14-2+(2*(*Q_synth)+w_tmp-32))); */
+ exp = sub( exp, sub( 30, add( sub( Energy_Q, exp_L ), 14 - 2 ) ) );
+
+ tmp = div_s( 16384, frac );
+ L_tmp = L_deposit_h( tmp );
+ Energy = Isqrt_lc( L_tmp, &exp ); /*Q(31-exp) */
+ Energy_16 = round_fx( L_shl( Energy, sub( exp, 15 ) ) ); /*Q0 */
+ }
+
+ test();
+#ifdef BASOP_NOGLOB
+ IF( LT_32( SWB_tenv[i], 65536 /* 2 in Q15 */ ) && LT_32( Energy, L_shl_sat( SWB_tenv[i], sub( 16, exp ) ) ) )
+#else
+ IF( LT_32( SWB_tenv[i], 65536 /* 2 in Q15 */ ) && LT_32( Energy, L_shl( SWB_tenv[i], sub( 16, exp ) ) ) )
+#endif
+ {
+ *Q_synth = add( *Q_synth, 3 );
+ move16();
+ }
+ ELSE
+ {
+ pit -= shr( L, 2 );
+ tmp_ener = 0;
+ move16();
+ exp = 0;
+ move16();
+
+ IF( Energy_16 != 0 )
+ {
+ exp = norm_s( Energy_16 );
+ tmp_ener = div_s( shl( 1, sub( 14, exp ) ), Energy_16 ); /*Q(29-exp) */
+ }
+
+ L_tmp = Mult_32_16( SWB_tenv[i], tmp_ener ); /*Q(29-exp) */
+ tmp = round_fx( L_tmp ); /*Q(13-exp) */
+
FOR( j = 0; j < L / 4; j++ )
{
#ifdef BASOP_NOGLOB
diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c
index d69fa852593acbfeb82f9af47792f4ad2fb6cd19..672e56f7ba29ca1df35c87ba1e13d63e5e4a029d 100644
--- a/lib_dec/ivas_jbm_dec.c
+++ b/lib_dec/ivas_jbm_dec.c
@@ -690,6 +690,14 @@ ivas_error ivas_jbm_dec_tc_fx(
test();
IF( EQ_32( st_ivas->ivas_format, MASA_FORMAT ) )
{
+#ifdef NONBE_FIX_1165_STATIC_SCAL_OMASA
+ IF( EQ_16( st_ivas->hMasa->config.input_ivas_format, MASA_ISM_FORMAT ) )
+ {
+ /* Revert scaling done to the downmix in the encoder */
+ ivas_omasa_gain_umx_fx( st_ivas, p_output_fx, output_frame );
+ }
+
+#endif
Word16 q_shift = 0;
move16();
ivas_masa_prerender_fx( st_ivas, p_output_fx, &q_shift, output_frame, nchan_remapped );
@@ -809,7 +817,11 @@ ivas_error ivas_jbm_dec_tc_fx(
{
hp20_fx_32( p_output_fx[n], output_frame, st_ivas->mem_hp20_out_fx[n], output_Fs );
}
+#ifdef NONBE_FIX_1165_STATIC_SCAL_OMASA
+ /* Revert scaling done to the downmix in the encoder */
+ ivas_omasa_gain_umx_fx( st_ivas, p_output_fx, output_frame );
+#endif
Word16 output_q = 11;
move16();
IF( EQ_32( st_ivas->renderer_type, RENDERER_MONO_DOWNMIX ) )
@@ -1275,7 +1287,14 @@ ivas_error ivas_jbm_dec_tc_fx(
{
hp20_fx_32( p_output_fx[n], output_frame, st_ivas->mem_hp20_out_fx[n], output_Fs );
}
-
+#ifdef NONBE_FIX_1165_STATIC_SCAL_PARAMMC
+ /* Revert scaling done to the downmix in the encoder */
+ FOR( n = 0; n < st_ivas->nchan_transport; n++ )
+ {
+ v_multc_fixed( p_output_fx[n], st_ivas->hParamMC->static_dmx_fac_fx, p_output_fx[n], output_frame );
+ scale_sig32( p_output_fx[n], output_frame, 2 );
+ }
+#endif
/* Rendering */
test();
IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_MONO ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_STEREO ) )
@@ -1336,6 +1355,11 @@ ivas_error ivas_jbm_dec_tc_fx(
{
return error;
}
+
+#ifdef NONBE_FIX_1165_STATIC_SCAL_MCMASA
+ /* Revert scaling done to the downmix in the encoder */
+ ivas_mcmasa_gain_umx_fx( st_ivas, p_output_fx, output_frame );
+#endif
test();
test();
test();
@@ -1382,8 +1406,11 @@ ivas_error ivas_jbm_dec_tc_fx(
Scale_sig32( p_output_fx[1], output_frame, sub( Q11, q_output ) ); // Q11
}
}
+#ifdef NONBE_FIX_1165_STATIC_SCAL_MCMASA
+ /* Revert scaling done to the downmix in the encoder */
+ ivas_mcmasa_gain_umx_fx( st_ivas, p_output_fx, output_frame );
+#endif
}
-
IF( st_ivas->sba_dirac_stereo_flag != 0 ) /* use the flag to trigger the DFT upmix */
{
Word16 q;
@@ -1575,7 +1602,6 @@ ivas_error ivas_jbm_dec_tc_fx(
return IVAS_ERR_OK;
}
-
/*--------------------------------------------------------------------------*
* ivas_jbm_dec_feed_tc_to_renderer()
*
@@ -1846,6 +1872,7 @@ void ivas_jbm_dec_feed_tc_to_renderer_fx(
return;
}
+
/*--------------------------------------------------------------------------*
* ivas_dec_render()
*
@@ -2582,7 +2609,7 @@ ivas_error ivas_jbm_dec_render_fx(
IF( NE_32( st_ivas->ivas_format, MONO_FORMAT ) )
{
#ifndef DISABLE_LIMITER
- ivas_limiter_dec_fx( st_ivas->hLimiter, p_output_fx, nchan_out, *nSamplesRendered, st_ivas->BER_detect, output_q_factor );
+ ivas_limiter_apply_fx( st_ivas->hLimiter, p_output_fx, nchan_out, *nSamplesRendered, st_ivas->BER_detect, output_q_factor );
#endif
}
}
@@ -2601,7 +2628,6 @@ ivas_error ivas_jbm_dec_render_fx(
*
* Flush samples if renderer granularity changes on a bitrate change
*--------------------------------------------------------------------------*/
-
ivas_error ivas_jbm_dec_flush_renderer_fx(
Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */
const Word16 tc_granularity_new, /* i : new renderer granularity */
@@ -2876,7 +2902,7 @@ ivas_error ivas_jbm_dec_flush_renderer_fx(
{
p_output_fx[ch_idx] = output_fx[ch_idx];
}
- ivas_limiter_dec_fx( st_ivas->hLimiter, p_output_fx, st_ivas->hDecoderConfig->nchan_out, *nSamplesRendered, st_ivas->BER_detect, exp );
+ ivas_limiter_apply_fx( st_ivas->hLimiter, p_output_fx, st_ivas->hDecoderConfig->nchan_out, *nSamplesRendered, st_ivas->BER_detect, exp );
#endif
}
}
diff --git a/lib_dec/ivas_masa_dec.c b/lib_dec/ivas_masa_dec.c
index 999eae9aa2f384b455d36744108c35867dc5ae23..42ba9f0da2f1f28ee54de9d9192591c1bc6cd785 100644
--- a/lib_dec/ivas_masa_dec.c
+++ b/lib_dec/ivas_masa_dec.c
@@ -506,6 +506,10 @@ ivas_error ivas_masa_decode_fx(
}
ELSE IF( st->bfi == 0 && EQ_32( ivas_format, MASA_FORMAT ) && EQ_32( ivas_total_brate, IVAS_SID_5k2 ) )
{
+#ifdef NONBE_FIX_1165_STATIC_SCAL_OMASA
+ hMasa->config.input_ivas_format = MASA_FORMAT; /* Default in SID as OMASA does not support SID */
+ move16();
+#endif
IF( hQMetaData->q_direction == NULL )
{
/* replicate ivas_masa_dec_config() in case that first good received frame is SID frame */
diff --git a/lib_dec/ivas_mc_param_dec.c b/lib_dec/ivas_mc_param_dec.c
index fc158ca89d75cd413ffdeb4b76b0b6efe2f31fa2..2d870fd732665e6dc2dc42439a2ced6704346e3a 100644
--- a/lib_dec/ivas_mc_param_dec.c
+++ b/lib_dec/ivas_mc_param_dec.c
@@ -364,7 +364,10 @@ ivas_error ivas_param_mc_dec_open_fx(
return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Parametric MC\n" ) );
}
Copy32( ivas_param_mc_conf[config_index].dmx_fac_fx, hParamMC->proto_matrix_int_fx, imult1616( nchan_transport, nchan_out_transport ) ); /*Q31*/
-
+#ifdef NONBE_FIX_1165_STATIC_SCAL_PARAMMC
+ hParamMC->static_dmx_fac_fx = ivas_param_mc_conf[config_index].static_dmx_fac_fx;
+ move32();
+#endif
hParamMC->proto_matrix_int_len = imult1616( nchan_out_transport, nchan_transport );
move16();
diff --git a/lib_dec/ivas_mcmasa_dec.c b/lib_dec/ivas_mcmasa_dec.c
index 3f5f1d098dbd6de796b595fa37ae5f0c1bf553f1..f43e9941288ee10765e15b638106cd7fa10b453a 100644
--- a/lib_dec/ivas_mcmasa_dec.c
+++ b/lib_dec/ivas_mcmasa_dec.c
@@ -38,6 +38,7 @@
#include "prot.h"
#include "wmc_auto.h"
#include "ivas_prot_fx.h"
+#include "prot_fx.h"
/*-------------------------------------------------------------------------
@@ -98,3 +99,106 @@ ivas_error ivas_mcmasa_dec_reconfig(
return error;
}
+
+#ifdef NONBE_FIX_1165_STATIC_SCAL_MCMASA
+
+/*-------------------------------------------------------------------------
+ * ivas_mcmasa_gain_umx()
+ *
+ * Gain decoded signals to match the gains applied to the downmix signals in the encoder
+ *------------------------------------------------------------------------*/
+void ivas_mcmasa_gain_umx_fx(
+ Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */
+ Word32 *data_f[], /* i/o: output signals Qx*/
+ const Word16 output_frame /* i : output frame length per channel */
+)
+{
+ Word32 gain;
+ Word16 nchan_transport;
+ UWord8 separateChannelEnabled;
+
+ nchan_transport = st_ivas->nchan_transport;
+ move16();
+ separateChannelEnabled = st_ivas->hOutSetup.separateChannelEnabled;
+ move16();
+ gain = ONE_IN_Q29;
+ move32();
+
+ IF( separateChannelEnabled )
+ {
+ /* Separate channel gaining */
+ v_multc_fixed( data_f[2], ivas_mcmasa_dmx_scal_fac_sep_chan_static_FX_IN_Q29, data_f[2], output_frame );
+ scale_sig32( data_f[2], output_frame, 2 );
+ /* Downmix channels gaining */
+ IF( EQ_16( st_ivas->transport_config, IVAS_AUDIO_CONFIG_5_1_4 ) )
+ {
+ gain = ivas_mcmasa_dmx_scal_fac_CICP16_3tc_static_FX_IN_Q29;
+ move32();
+ }
+ ELSE IF( EQ_16( st_ivas->transport_config, IVAS_AUDIO_CONFIG_7_1_4 ) )
+ {
+ gain = ivas_mcmasa_dmx_scal_fac_CICP19_3tc_static_FX_IN_Q29;
+ move32();
+ }
+
+ v_multc_fixed( data_f[0], gain, data_f[0], output_frame );
+ v_multc_fixed( data_f[1], gain, data_f[1], output_frame );
+ scale_sig32( data_f[0], output_frame, 2 );
+ scale_sig32( data_f[1], output_frame, 2 );
+ }
+ ELSE
+ {
+ IF( EQ_16( nchan_transport, 2 ) )
+ {
+ IF( EQ_16( st_ivas->transport_config, IVAS_AUDIO_CONFIG_5_1_4 ) )
+ {
+ gain = ivas_mcmasa_dmx_scal_fac_CICP16_2tc_static_FX_IN_Q29;
+ move32();
+ }
+ ELSE IF( EQ_16( st_ivas->transport_config, IVAS_AUDIO_CONFIG_7_1_4 ) )
+ {
+ gain = ivas_mcmasa_dmx_scal_fac_CICP19_2tc_static_FX_IN_Q29;
+ move32();
+ }
+
+ v_multc_fixed( data_f[0], gain, data_f[0], output_frame );
+ v_multc_fixed( data_f[1], gain, data_f[1], output_frame );
+ scale_sig32( data_f[0], output_frame, 2 );
+ scale_sig32( data_f[1], output_frame, 2 );
+ }
+ ELSE
+ {
+ IF( EQ_16( st_ivas->transport_config, IVAS_AUDIO_CONFIG_5_1 ) )
+ {
+ gain = ivas_mcmasa_dmx_scal_fac_CICP6_1tc_static_FX_IN_Q29;
+ move32();
+ }
+ ELSE IF( EQ_16( st_ivas->transport_config, IVAS_AUDIO_CONFIG_7_1 ) )
+ {
+ gain = ivas_mcmasa_dmx_scal_fac_CICP12_1tc_static_FX_IN_Q29;
+ move32();
+ }
+ ELSE IF( EQ_16( st_ivas->transport_config, IVAS_AUDIO_CONFIG_5_1_2 ) )
+ {
+ gain = ivas_mcmasa_dmx_scal_fac_CICP14_1tc_static_FX_IN_Q29;
+ move32();
+ }
+ ELSE IF( EQ_16( st_ivas->transport_config, IVAS_AUDIO_CONFIG_5_1_4 ) )
+ {
+ gain = ivas_mcmasa_dmx_scal_fac_CICP16_1tc_static_FX_IN_Q29;
+ move32();
+ }
+ ELSE IF( EQ_16( st_ivas->transport_config, IVAS_AUDIO_CONFIG_7_1_4 ) )
+ {
+ gain = ivas_mcmasa_dmx_scal_fac_CICP19_1tc_static_FX_IN_Q29;
+ move32();
+ }
+
+ v_multc_fixed( data_f[0], gain, data_f[0], output_frame );
+ scale_sig32( data_f[0], output_frame, 2 );
+ }
+ }
+
+ return;
+}
+#endif
diff --git a/lib_dec/ivas_omasa_dec.c b/lib_dec/ivas_omasa_dec.c
index 50921761651bd8e790087ebe28274583bcce4826..ee455d28df3fb767b0413c9963efb3c04404757d 100644
--- a/lib_dec/ivas_omasa_dec.c
+++ b/lib_dec/ivas_omasa_dec.c
@@ -828,3 +828,86 @@ void ivas_omasa_rearrange_channels_fx(
return;
}
+#ifdef NONBE_FIX_1165_STATIC_SCAL_OMASA
+
+/*--------------------------------------------------------------------------*
+ * ivas_omasa_gain_umx()
+ *
+ * Gain decoded signals to match the gains applied to the downmix signals in the encoder
+ *--------------------------------------------------------------------------*/
+void ivas_omasa_gain_umx_fx(
+ Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */
+ Word32 *data_f[], /* i/o: output signals Qx*/
+ const Word16 output_frame /* i : output frame length per channel */
+)
+{
+ Word32 gain;
+ Word16 nchan_ism;
+
+ nchan_ism = st_ivas->nchan_ism;
+ move16();
+ gain = ONE_IN_Q29;
+ move32();
+
+ test();
+ test();
+ test();
+ test();
+ IF( EQ_16( st_ivas->ivas_format, MASA_FORMAT ) && EQ_16( st_ivas->hMasa->config.input_ivas_format, MASA_ISM_FORMAT ) )
+ {
+ /* Full downmix mode */
+ IF( EQ_16( nchan_ism, 1 ) )
+ {
+ gain = ivas_omasa_dmx_scal_fac_2ch_static_FX_IN_Q29;
+ move32();
+ }
+ ELSE IF( EQ_16( nchan_ism, 2 ) )
+ {
+ gain = ivas_omasa_dmx_scal_fac_3ch_static_FX_IN_Q29;
+ move32();
+ }
+ ELSE IF( EQ_16( nchan_ism, 3 ) )
+ {
+ gain = ivas_omasa_dmx_scal_fac_4ch_static_FX_IN_Q29;
+ move32();
+ }
+ ELSE IF( EQ_16( nchan_ism, 4 ) )
+ {
+ gain = ivas_omasa_dmx_scal_fac_5ch_static_FX_IN_Q29;
+ move32();
+ }
+ }
+ ELSE IF( EQ_16( st_ivas->ivas_format, MASA_ISM_FORMAT ) && ( EQ_16( st_ivas->ism_mode, ISM_MASA_MODE_MASA_ONE_OBJ ) || EQ_16( st_ivas->ism_mode, ISM_MASA_MODE_PARAM_ONE_OBJ ) ) )
+ {
+ /* One separated object + downmix mode */
+ IF( EQ_16( nchan_ism, 2 ) )
+ {
+ gain = ivas_omasa_dmx_scal_fac_2ch_static_FX_IN_Q29;
+ move32();
+ }
+ ELSE IF( EQ_16( nchan_ism, 3 ) )
+ {
+ gain = ivas_omasa_dmx_scal_fac_3ch_static_FX_IN_Q29;
+ move32();
+ }
+ ELSE IF( EQ_16( nchan_ism, 4 ) )
+ {
+ gain = ivas_omasa_dmx_scal_fac_4ch_static_FX_IN_Q29;
+ move32();
+ }
+ }
+ ELSE
+ {
+ /* Skip gain */
+ return;
+ }
+
+ v_multc_fixed( data_f[0], gain, data_f[0], output_frame );
+ v_multc_fixed( data_f[1], gain, data_f[1], output_frame );
+
+ scale_sig32( data_f[0], output_frame, 2 );
+ scale_sig32( data_f[1], output_frame, 2 );
+
+ return;
+}
+#endif
diff --git a/lib_dec/ivas_out_setup_conversion.c b/lib_dec/ivas_out_setup_conversion.c
index fbbe2a6fe6e5e536e704f74d781635cc64d7780a..6a955ddaf80ecd302138d267b93dd5ff867ac2a5 100644
--- a/lib_dec/ivas_out_setup_conversion.c
+++ b/lib_dec/ivas_out_setup_conversion.c
@@ -50,11 +50,9 @@
*----------------------------------------------------------------------------------*/
-#define LS_OUT_CONV_SMOOTHING_FACTOR_Q31 93415539
-#define LS_OUT_CONV_CLIP_FACTOR_MAX_Q29 1073741824
-#define LS_OUT_CONV_CLIP_FACTOR_MAX_SQ_Q28 1073741824
-#define LS_OUT_CONV_CLIP_FACTOR_MIN_Q29 161061274
-#define LS_OUT_CONV_CLIP_FACTOR_MIN_SQ_Q28 24159191
+#define LS_OUT_CONV_SMOOTHING_FACTOR_Q31 93415539
+#define LS_OUT_CONV_CLIP_FACTOR_MAX_Q30 2147483647
+#define LS_OUT_CONV_CLIP_FACTOR_MIN_Q30 322122547
/*----------------------------------------------------------------------------------*
@@ -62,24 +60,12 @@
*----------------------------------------------------------------------------------*/
static void ivas_lssetupconversion_computeEQFactor_fx(
- Word32 *outputEnergy, // Q0
- Word32 *inputEnergy, // Q0
+ Word32 *outputEnergy,
+ Word16 output_exp,
+ Word32 *inputEnergy,
+ Word16 input_exp,
Word32 *EQ )
{
-
- IF( GE_32( L_shr( *outputEnergy, 3 ), Mpy_32_32( LS_OUT_CONV_CLIP_FACTOR_MAX_SQ_Q28, *inputEnergy ) ) )
- {
- *EQ = L_shl_sat( LS_OUT_CONV_CLIP_FACTOR_MAX_Q29, 1 ); // Q30
- move32();
- return;
- }
- IF( LE_32( L_shr( *outputEnergy, 3 ), Mpy_32_32( LS_OUT_CONV_CLIP_FACTOR_MIN_SQ_Q28, *inputEnergy ) ) )
- {
- *EQ = L_shl_sat( LS_OUT_CONV_CLIP_FACTOR_MIN_Q29, 1 ); // Q30
- move32();
- return;
- }
-
test();
IF( ( *outputEnergy == 0 ) && ( *inputEnergy == 0 ) )
{
@@ -90,9 +76,16 @@ static void ivas_lssetupconversion_computeEQFactor_fx(
/* Compute the Equalization Gain */
Word16 tmp_e;
Word16 tmp = BASOP_Util_Divide3232_Scale( *outputEnergy, L_add( EPSILON_FX, *inputEnergy ), &tmp_e );
- Word32 tmp_32 = L_shl( (Word32) tmp, 16 );
+ tmp_e = add( tmp_e, sub( output_exp, input_exp ) );
+ Word32 tmp_32 = L_deposit_h( tmp );
tmp_32 = Sqrt32( tmp_32, &tmp_e );
- *EQ = L_shr( tmp_32, 1 - tmp_e );
+ *EQ = L_shr_sat( tmp_32, sub( 1, tmp_e ) ); // range of EQ in float 0.3 - 2.0
+ move32();
+
+ *EQ = L_min( *EQ, LS_OUT_CONV_CLIP_FACTOR_MAX_Q30 );
+ *EQ = L_max( *EQ, LS_OUT_CONV_CLIP_FACTOR_MIN_Q30 );
+ move32();
+ move32();
return;
}
@@ -437,10 +430,10 @@ ivas_error ivas_ls_setup_conversion_open_fx(
return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LS configuration Conversion Handle \n" ) );
}
set32_fx( hLsSetUpConversion->targetEnergyPrev_fx[chIdx], 0, hLsSetUpConversion->sfbCnt );
- hLsSetUpConversion->te_prev_exp = 0;
+ hLsSetUpConversion->te_prev_exp[chIdx] = 0;
move16();
set32_fx( hLsSetUpConversion->dmxEnergyPrev_fx[chIdx], 0, hLsSetUpConversion->sfbCnt );
- hLsSetUpConversion->dmx_prev_exp = 0;
+ hLsSetUpConversion->dmx_prev_exp[chIdx] = 0;
move16();
}
FOR( ; chIdx < MAX_CICP_CHANNELS; chIdx++ )
@@ -857,22 +850,32 @@ void ivas_ls_setup_conversion_process_mdct_fx(
} /* end of out channel loop */
/* Step 3: Peform energy smoothing */
+
+ Word16 te_scale = getScaleFactor32( hLsSetUpConversion->targetEnergyPrev_fx[0], hLsSetUpConversion->sfbCnt );
+ scale_sig32( hLsSetUpConversion->targetEnergyPrev_fx[0], hLsSetUpConversion->sfbCnt, te_scale );
+ Word16 dmx_sacle = getScaleFactor32( hLsSetUpConversion->dmxEnergyPrev_fx[0], hLsSetUpConversion->sfbCnt );
+ scale_sig32( hLsSetUpConversion->dmxEnergyPrev_fx[0], hLsSetUpConversion->sfbCnt, dmx_sacle );
+
+ Word16 te_max_e = s_max( sub( 40, shl( q_output, 1 ) ), sub( hLsSetUpConversion->te_prev_exp[0], te_scale ) );
+ Word16 dmx_max_e = s_max( sub( 40, shl( q_output, 1 ) ), sub( hLsSetUpConversion->dmx_prev_exp[0], dmx_sacle ) );
+
FOR( bandIdx = 0; bandIdx < hLsSetUpConversion->sfbCnt; bandIdx++ )
{
- targetEnergy[bandIdx] = L_add( Mpy_32_32( LS_OUT_CONV_SMOOTHING_FACTOR_Q31, targetEnergy[bandIdx] ), Mpy_32_32( ( ONE_IN_Q31 - LS_OUT_CONV_SMOOTHING_FACTOR_Q31 ), hLsSetUpConversion->targetEnergyPrev_fx[0][bandIdx] ) );
+ targetEnergy[bandIdx] = L_add( Mpy_32_32( LS_OUT_CONV_SMOOTHING_FACTOR_Q31, L_shr( targetEnergy[bandIdx], sub( te_max_e, sub( 40, shl( q_output, 1 ) ) ) ) ), Mpy_32_32( ( ONE_IN_Q31 - LS_OUT_CONV_SMOOTHING_FACTOR_Q31 ), L_shr( hLsSetUpConversion->targetEnergyPrev_fx[0][bandIdx], sub( te_max_e, sub( hLsSetUpConversion->te_prev_exp[0], te_scale ) ) ) ) );
move32();
- dmxEnergy[bandIdx] = L_add( Mpy_32_32( LS_OUT_CONV_SMOOTHING_FACTOR_Q31, dmxEnergy[bandIdx] ), Mpy_32_32( ( ONE_IN_Q31 - LS_OUT_CONV_SMOOTHING_FACTOR_Q31 ), hLsSetUpConversion->dmxEnergyPrev_fx[0][bandIdx] ) );
+ dmxEnergy[bandIdx] = L_add( Mpy_32_32( LS_OUT_CONV_SMOOTHING_FACTOR_Q31, L_shr( dmxEnergy[bandIdx], sub( dmx_max_e, sub( 40, shl( q_output, 1 ) ) ) ) ), Mpy_32_32( ( ONE_IN_Q31 - LS_OUT_CONV_SMOOTHING_FACTOR_Q31 ), L_shr( hLsSetUpConversion->dmxEnergyPrev_fx[0][bandIdx], sub( dmx_max_e, sub( hLsSetUpConversion->dmx_prev_exp[0], dmx_sacle ) ) ) ) );
move32();
- hLsSetUpConversion->targetEnergyPrev_fx[0][bandIdx] = targetEnergy[bandIdx]; // exp( hLsSetUpConversion->te_prev_exp) (Q0 here)
+ hLsSetUpConversion->targetEnergyPrev_fx[0][bandIdx] = targetEnergy[bandIdx]; /* te_prev_exp = 40 - 2*q_output */
move32();
- hLsSetUpConversion->dmxEnergyPrev_fx[0][bandIdx] = dmxEnergy[bandIdx]; // exp( hLsSetUpConversion->dmx_prev_exp) (Q0)
+ hLsSetUpConversion->dmxEnergyPrev_fx[0][bandIdx] = dmxEnergy[bandIdx]; /* dmx_prev_exp = 40 - 2*q_output */
move32();
- hLsSetUpConversion->te_prev_exp = 31;
- move16();
- hLsSetUpConversion->dmx_prev_exp = 31;
- move16();
}
+ hLsSetUpConversion->te_prev_exp[0] = te_max_e; /* te_prev_exp = 40 - 2*q_output */
+ move16();
+ hLsSetUpConversion->dmx_prev_exp[0] = dmx_max_e; /* dmx_prev_exp = 40 - 2*q_output */
+ move16();
+
FOR( i = 0; i < inChannels; ++i )
{
FOR( j = 0; j < L_FRAME48k; ++j )
@@ -901,7 +904,7 @@ void ivas_ls_setup_conversion_process_mdct_fx(
move16();
/* Compute Eq gains */
- ivas_lssetupconversion_computeEQFactor_fx( &targetEnergy[bandIdx], &dmxEnergy[bandIdx], &eqGain ); // Q(eqGain) = 30
+ ivas_lssetupconversion_computeEQFactor_fx( &targetEnergy[bandIdx], hLsSetUpConversion->te_prev_exp[0], &dmxEnergy[bandIdx], hLsSetUpConversion->dmx_prev_exp[0], &eqGain ); // Q(eqGain) = 30
FOR( binIdx = start; binIdx < stop; binIdx++ )
{
x[chInIdx][0][binIdx] = Mpy_32_32( L_shl( x[chInIdx][0][binIdx], 1 ), eqGain ); // Q - 1
@@ -921,7 +924,7 @@ void ivas_ls_setup_conversion_process_mdct_fx(
move16();
/* Compute Eq gains */
- ivas_lssetupconversion_computeEQFactor_fx( &targetEnergy[bandIdx], &dmxEnergy[bandIdx], &eqGain );
+ ivas_lssetupconversion_computeEQFactor_fx( &targetEnergy[bandIdx], hLsSetUpConversion->te_prev_exp[0], &dmxEnergy[bandIdx], hLsSetUpConversion->dmx_prev_exp[0], &eqGain );
FOR( subFrameIdx = 0; subFrameIdx < NB_DIV; subFrameIdx++ )
{
@@ -1261,18 +1264,18 @@ void ivas_ls_setup_conversion_process_mdct_param_mc_fx(
/* Step 3: Peform energy smoothing */
FOR( bandIdx = 0; bandIdx < hLsSetUpConversion->sfbCnt; bandIdx++ )
{
- targetEnergy_fx[bandIdx] = L_add( Mult_32_32( LS_OUT_CONV_SMOOTHING_FACTOR_Q31, targetEnergy_fx[bandIdx] ), Mult_32_32( L_sub( MAX_32, LS_OUT_CONV_SMOOTHING_FACTOR_Q31 ), L_shr( hLsSetUpConversion->targetEnergyPrev_fx[0][bandIdx], add( output_exp, sub( 2, hLsSetUpConversion->te_prev_exp ) ) ) ) ); /*output_exp + 2*/
+ targetEnergy_fx[bandIdx] = L_add( Mult_32_32( LS_OUT_CONV_SMOOTHING_FACTOR_Q31, targetEnergy_fx[bandIdx] ), Mult_32_32( L_sub( MAX_32, LS_OUT_CONV_SMOOTHING_FACTOR_Q31 ), L_shr( hLsSetUpConversion->targetEnergyPrev_fx[0][bandIdx], add( output_exp, sub( 2, hLsSetUpConversion->te_prev_exp[0] ) ) ) ) ); /*output_exp + 2*/
move32();
- dmxEnergy_fx[bandIdx] = L_add( Mult_32_32( LS_OUT_CONV_SMOOTHING_FACTOR_Q31, dmxEnergy_fx[bandIdx] ), Mult_32_32( L_sub( MAX_32, LS_OUT_CONV_SMOOTHING_FACTOR_Q31 ), L_shr( hLsSetUpConversion->dmxEnergyPrev_fx[0][bandIdx], sub( shl( add( max_e, 2 ), 1 ), hLsSetUpConversion->dmx_prev_exp ) ) ) ); /*2 * (max_e + 2)*/
+ dmxEnergy_fx[bandIdx] = L_add( Mult_32_32( LS_OUT_CONV_SMOOTHING_FACTOR_Q31, dmxEnergy_fx[bandIdx] ), Mult_32_32( L_sub( MAX_32, LS_OUT_CONV_SMOOTHING_FACTOR_Q31 ), L_shr( hLsSetUpConversion->dmxEnergyPrev_fx[0][bandIdx], sub( shl( add( max_e, 2 ), 1 ), hLsSetUpConversion->dmx_prev_exp[0] ) ) ) ); /*2 * (max_e + 2)*/
move32();
hLsSetUpConversion->targetEnergyPrev_fx[0][bandIdx] = targetEnergy_fx[bandIdx];
move32();
hLsSetUpConversion->dmxEnergyPrev_fx[0][bandIdx] = dmxEnergy_fx[bandIdx];
move32();
}
- hLsSetUpConversion->te_prev_exp = add( output_exp, 2 );
+ hLsSetUpConversion->te_prev_exp[0] = add( output_exp, 2 );
move16();
- hLsSetUpConversion->dmx_prev_exp = shl( add( max_e, 2 ), 1 );
+ hLsSetUpConversion->dmx_prev_exp[0] = shl( add( max_e, 2 ), 1 );
move16();
/* Step 4: Perform equalization */
FOR( chInIdx = 0; chInIdx < nchan_transport; chInIdx++ )
@@ -1290,7 +1293,7 @@ void ivas_ls_setup_conversion_process_mdct_param_mc_fx(
move16();
/*Compute Eq gains */
- ivas_lssetupconversion_computeEQFactor_fx( &targetEnergy_fx[bandIdx], &dmxEnergy_fx[bandIdx], &eqGain_fx );
+ ivas_lssetupconversion_computeEQFactor_fx( &targetEnergy_fx[bandIdx], hLsSetUpConversion->te_prev_exp[0], &dmxEnergy_fx[bandIdx], hLsSetUpConversion->dmx_prev_exp[0], &eqGain_fx );
FOR( binIdx = start; binIdx < stop; binIdx++ )
{
@@ -1308,7 +1311,7 @@ void ivas_ls_setup_conversion_process_mdct_param_mc_fx(
stop = shr( hLsSetUpConversion->sfbOffset[bandIdx + 1], 1 );
/*Compute Eq gains */
- ivas_lssetupconversion_computeEQFactor_fx( &targetEnergy_fx[bandIdx], &dmxEnergy_fx[bandIdx], &eqGain_fx );
+ ivas_lssetupconversion_computeEQFactor_fx( &targetEnergy_fx[bandIdx], hLsSetUpConversion->te_prev_exp[0], &dmxEnergy_fx[bandIdx], hLsSetUpConversion->dmx_prev_exp[0], &eqGain_fx );
FOR( subFrameIdx = 0; subFrameIdx < NB_DIV; subFrameIdx++ )
@@ -1481,21 +1484,30 @@ void ivas_lssetupconversion_process_param_mc_fx(
{
IF( channel_active[chOutIdx] )
{
+ Word16 te_scale = getScaleFactor32( hLsSetUpConversion->targetEnergyPrev_fx[chOutIdx], hLsSetUpConversion->sfbCnt );
+ scale_sig32( hLsSetUpConversion->targetEnergyPrev_fx[chOutIdx], hLsSetUpConversion->sfbCnt, te_scale );
+ Word16 dmx_sacle = getScaleFactor32( hLsSetUpConversion->dmxEnergyPrev_fx[chOutIdx], hLsSetUpConversion->sfbCnt );
+ scale_sig32( hLsSetUpConversion->dmxEnergyPrev_fx[chOutIdx], hLsSetUpConversion->sfbCnt, dmx_sacle );
+
+ Word16 te_max_e = s_max( sub( 50, shl( q_output, 1 ) ), sub( hLsSetUpConversion->te_prev_exp[chOutIdx], te_scale ) );
+ Word16 dmx_max_e = s_max( sub( 50, shl( q_output, 1 ) ), sub( hLsSetUpConversion->dmx_prev_exp[chOutIdx], dmx_sacle ) );
+
FOR( bandIdx = 0; bandIdx < hLsSetUpConversion->sfbCnt; bandIdx++ )
{
- targetEnergy[chOutIdx][bandIdx] = L_add( Mpy_32_32( LS_OUT_CONV_SMOOTHING_FACTOR_Q31, targetEnergy[chOutIdx][bandIdx] ), Mpy_32_32( L_sub( ONE_IN_Q31, LS_OUT_CONV_SMOOTHING_FACTOR_Q31 ), hLsSetUpConversion->targetEnergyPrev_fx[chOutIdx][bandIdx] ) );
+ targetEnergy[chOutIdx][bandIdx] = L_add( Mpy_32_32( LS_OUT_CONV_SMOOTHING_FACTOR_Q31, L_shr( targetEnergy[chOutIdx][bandIdx], sub( te_max_e, sub( 50, shl( q_output, 1 ) ) ) ) ), Mpy_32_32( L_sub( ONE_IN_Q31, LS_OUT_CONV_SMOOTHING_FACTOR_Q31 ), L_shr( hLsSetUpConversion->targetEnergyPrev_fx[chOutIdx][bandIdx], sub( te_max_e, sub( hLsSetUpConversion->te_prev_exp[chOutIdx], te_scale ) ) ) ) );
move32();
- dmxEnergy[chOutIdx][bandIdx] = L_add( Mpy_32_32( LS_OUT_CONV_SMOOTHING_FACTOR_Q31, dmxEnergy[chOutIdx][bandIdx] ), Mpy_32_32( L_sub( ONE_IN_Q31, LS_OUT_CONV_SMOOTHING_FACTOR_Q31 ), hLsSetUpConversion->dmxEnergyPrev_fx[chOutIdx][bandIdx] ) );
+ dmxEnergy[chOutIdx][bandIdx] = L_add( Mpy_32_32( LS_OUT_CONV_SMOOTHING_FACTOR_Q31, L_shr( dmxEnergy[chOutIdx][bandIdx], sub( dmx_max_e, sub( 50, shl( q_output, 1 ) ) ) ) ), Mpy_32_32( L_sub( ONE_IN_Q31, LS_OUT_CONV_SMOOTHING_FACTOR_Q31 ), L_shr( hLsSetUpConversion->dmxEnergyPrev_fx[chOutIdx][bandIdx], sub( dmx_max_e, sub( hLsSetUpConversion->dmx_prev_exp[chOutIdx], dmx_sacle ) ) ) ) );
move32();
hLsSetUpConversion->targetEnergyPrev_fx[chOutIdx][bandIdx] = targetEnergy[chOutIdx][bandIdx]; // Q0
move32();
hLsSetUpConversion->dmxEnergyPrev_fx[chOutIdx][bandIdx] = dmxEnergy[chOutIdx][bandIdx]; // Q0
move32();
- hLsSetUpConversion->te_prev_exp = 31;
- move16();
- hLsSetUpConversion->dmx_prev_exp = 31;
- move16();
}
+
+ hLsSetUpConversion->te_prev_exp[chOutIdx] = te_max_e; /* te_prev_exp = 50 - 2*q_output */
+ move16();
+ hLsSetUpConversion->dmx_prev_exp[chOutIdx] = dmx_max_e; /* dmx_prev_exp = 50 - 2*q_output */
+ move16();
}
}
@@ -1517,7 +1529,7 @@ void ivas_lssetupconversion_process_param_mc_fx(
{
FOR( bandIdx = 0; bandIdx < hLsSetUpConversion->sfbCnt; bandIdx++ )
{
- ivas_lssetupconversion_computeEQFactor_fx( &targetEnergy[chOutIdx][bandIdx], &dmxEnergy[chOutIdx][bandIdx], &EQ ); // Q(EQ) = Q30
+ ivas_lssetupconversion_computeEQFactor_fx( &targetEnergy[chOutIdx][bandIdx], hLsSetUpConversion->te_prev_exp[chOutIdx], &dmxEnergy[chOutIdx][bandIdx], hLsSetUpConversion->dmx_prev_exp[chOutIdx], &EQ ); // Q(EQ) = Q30
Cldfb_RealBuffer_InOut[chOutIdx][slotIdx][bandIdx] = Mpy_32_32( L_shl( Cldfb_RealBuffer_InOut[chOutIdx][slotIdx][bandIdx], 1 ), EQ );
move32();
Cldfb_ImagBuffer_InOut[chOutIdx][slotIdx][bandIdx] = Mpy_32_32( L_shl( Cldfb_ImagBuffer_InOut[chOutIdx][slotIdx][bandIdx], 1 ), EQ );
diff --git a/lib_dec/ivas_range_uni_dec.c b/lib_dec/ivas_range_uni_dec.c
index 785d5e9f5fab45c3341e2200eddf200ac93839fc..3da244dd875ca003fc9ffdfedf8c716b23b3241f 100644
--- a/lib_dec/ivas_range_uni_dec.c
+++ b/lib_dec/ivas_range_uni_dec.c
@@ -397,7 +397,7 @@ UWord16 rc_uni_dec_read_bits(
FOR( tmp = range; tmp <= low; tmp += range )
{
- val = add( val, 1 );
+ val = UL_addNsD( val, 1 );
}
/* in case of bitstream errors it is possible that val >= (1 << bits) */
diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h
index cf01ce54fcb68678e8891aec18b491652f22bd0d..50bc152b9ea17e35c25cc43aeb85279bb48a1617 100644
--- a/lib_dec/ivas_stat_dec.h
+++ b/lib_dec/ivas_stat_dec.h
@@ -573,7 +573,9 @@ typedef struct ivas_param_mc_dec_data_structure
Word32 *proto_matrix_int_fx;
Word16 proto_matrix_int_len;
Word16 proto_matrix_int_e;
-
+#ifdef NONBE_FIX_1165_STATIC_SCAL_PARAMMC
+ Word32 static_dmx_fac_fx;
+#endif
/*sub-modules*/
HANDLE_DIRAC_DECORR_PARAMS h_freq_domain_decorr_ap_params;
HANDLE_DIRAC_DECORR_STATE h_freq_domain_decorr_ap_state;
diff --git a/lib_dec/swb_bwe_dec.c b/lib_dec/swb_bwe_dec.c
index 1dcc5c111603f6ac4fbb50eeb0838ddcfc83d865..0f9863bdfc2bc874bbb7f9618a01d84365d71819 100644
--- a/lib_dec/swb_bwe_dec.c
+++ b/lib_dec/swb_bwe_dec.c
@@ -579,7 +579,8 @@ Word16 swb_bwe_dec_fx32(
}
/* time envelope shaping when the current frame is TRANSIENT frame */
- time_envelop_shaping_fx( hb_synth_fx16, SWB_tenv_tmp_fx, output_frame, &Q_syn_hb );
+ time_envelop_shaping_ivas_fx( hb_synth_fx16, SWB_tenv_tmp_fx, output_frame, &Q_syn_hb );
+
Q_syn_hb = sub( Q_syn_hb, 3 );
hBWE_FD->prev_td_energy_fx = SWB_tenv_fx[3];
diff --git a/lib_enc/ivas_enc.c b/lib_enc/ivas_enc.c
index bf9cc3c34c520d2452eccdb2d31f5fd5c9b0dff2..f2709b11f9fb43ba551113cbd43ed226bc8ec8c1 100644
--- a/lib_enc/ivas_enc.c
+++ b/lib_enc/ivas_enc.c
@@ -199,6 +199,14 @@ ivas_error ivas_enc_fx(
/* Stereo DMX generation */
ivas_param_ism_stereo_dmx_fx( st_ivas, data_fx, input_frame );
+ FOR( i = 0; i < st_ivas->hEncoderConfig->nchan_ism; i++ )
+ {
+ scale_sig32( data_fx[i], input_frame, sub( st_ivas->q_data_fx, Q14 ) ); // Q14 -> Q11
+ }
+#ifdef NONBE_FIX_1165_APPLY_LIMITER_ON_ENCODER_DMX
+ /* Apply limiter on downmix */
+ ivas_limiter_apply_fx( st_ivas->hLimiter, data_fx, MAX_PARAM_ISM_WAVE, input_frame, 0, st_ivas->q_data_fx );
+#endif
/* Core coding of Stereo DMX */
IF( NE_32( ( error = ivas_ism_enc_fx( st_ivas, data_fx, st_ivas->q_data_fx, input_frame, nb_bits_metadata, 0 ) ), IVAS_ERR_OK ) )
{
@@ -273,6 +281,11 @@ ivas_error ivas_enc_fx(
IF( EQ_32( ivas_format, SBA_FORMAT ) )
{
ivas_sba_getTCs_fx( data_fx, st_ivas, input_frame );
+#ifdef NONBE_FIX_1165_APPLY_LIMITER_ON_ENCODER_DMX
+
+ /* Apply limiter on transport channels */
+ ivas_limiter_apply_fx( st_ivas->hLimiter, data_fx, st_ivas->nchan_transport, input_frame, 0, st_ivas->q_data_fx );
+#endif
}
/* core-coding of transport channels */
@@ -356,6 +369,10 @@ ivas_error ivas_enc_fx(
q_data_separated_object = st_ivas->q_data_fx;
move16();
+#ifdef NONBE_FIX_1165_APPLY_LIMITER_ON_ENCODER_DMX
+ /* Apply limiter on downmix */
+ ivas_limiter_apply_fx( st_ivas->hLimiter, &data_fx[hEncoderConfig->nchan_ism], CPE_CHANNELS, input_frame, 0, st_ivas->q_data_fx );
+#endif
}
/* Encode ISMs transport channels */
@@ -466,6 +483,11 @@ ivas_error ivas_enc_fx(
hEncoderConfig->sba_planar = planar_sba_orig;
move16();
+#ifdef NONBE_FIX_1165_APPLY_LIMITER_ON_ENCODER_DMX
+
+ /* Apply limiter on SBA channels */
+ ivas_limiter_apply_fx( st_ivas->hLimiter, data_fx, st_ivas->nchan_transport, input_frame, 0, Q11 );
+#endif
}
ELSE
{
@@ -486,6 +508,11 @@ ivas_error ivas_enc_fx(
/* get SBA TCs */
ivas_sba_getTCs_fx( &data_fx[n], st_ivas, input_frame );
+#ifdef NONBE_FIX_1165_APPLY_LIMITER_ON_ENCODER_DMX
+
+ /* Apply limiter on SBA channels */
+ ivas_limiter_apply_fx( st_ivas->hLimiter, &data_fx[n], st_ivas->nchan_transport, input_frame, 0, Q11 );
+#endif
}
/* core-coding of transport channels */
@@ -581,6 +608,10 @@ ivas_error ivas_enc_fx(
/* encode Parametric MC parameters and write bitstream */
ivas_param_mc_enc_fx( st_ivas, hMetaData, data_fx, input_frame );
+#ifdef NONBE_FIX_1165_APPLY_LIMITER_ON_ENCODER_DMX
+ /* Apply limiter on downmix */
+ ivas_limiter_apply_fx( st_ivas->hLimiter, data_fx, st_ivas->nchan_transport, input_frame, 0, st_ivas->q_data_fx );
+#endif
IF( EQ_16( st_ivas->nCPE, 1 ) ) /* Stereo DMX */
{
IF( NE_32( ( error = ivas_cpe_enc_fx( st_ivas, 0, data_fx[0], data_fx[1], st_ivas->q_data_fx, input_frame, hMetaData->nb_bits_tot ) ), IVAS_ERR_OK ) )
@@ -631,7 +662,10 @@ ivas_error ivas_enc_fx(
{
return error;
}
-
+#ifdef NONBE_FIX_1165_APPLY_LIMITER_ON_ENCODER_DMX
+ /* Apply limiter on downmix */
+ ivas_limiter_apply_fx( st_ivas->hLimiter, data_fx, st_ivas->hMcMasa->separateChannelEnabled ? add( st_ivas->nchan_transport, 1 ) : st_ivas->nchan_transport, input_frame, 0, st_ivas->q_data_fx );
+#endif
IF( st_ivas->hMcMasa->separateChannelEnabled )
{
IF( NE_32( ( error = ivas_sce_enc_fx( st_ivas, 0, data_fx[2], st_ivas->q_data_fx, input_frame, 0 ) ), IVAS_ERR_OK ) )
diff --git a/lib_enc/ivas_init_enc.c b/lib_enc/ivas_init_enc.c
index 83c6655f0af5d05ac822902bf30c0a85cd131046..60c5017cd84cc637d6681bb3af311e92f5d929c2 100644
--- a/lib_enc/ivas_init_enc.c
+++ b/lib_enc/ivas_init_enc.c
@@ -439,6 +439,11 @@ void ivas_initialize_handles_enc(
/* OSBA handle */
st_ivas->hOSba = NULL;
+#ifdef NONBE_FIX_1165_APPLY_LIMITER_ON_ENCODER_DMX
+ /* Limiter handle */
+ st_ivas->hLimiter = NULL;
+
+#endif
return;
}
@@ -628,6 +633,12 @@ ivas_error ivas_init_encoder(
{
return error;
}
+#ifdef NONBE_FIX_1165_APPLY_LIMITER_ON_ENCODER_DMX
+ if ( ( error = ivas_limiter_open_fx( &st_ivas->hLimiter, MAX_PARAM_ISM_WAVE, st_ivas->hEncoderConfig->input_Fs ) ) != IVAS_ERR_OK )
+ {
+ return error;
+ }
+#endif
}
if ( st_ivas->hEncoderConfig->Opt_DTX_ON )
@@ -709,6 +720,17 @@ ivas_error ivas_init_encoder(
return error;
}
}
+
+#ifdef NONBE_FIX_1165_APPLY_LIMITER_ON_ENCODER_DMX
+
+ if ( ivas_format == SBA_FORMAT )
+ {
+ if ( ( error = ivas_limiter_open_fx( &st_ivas->hLimiter, HOA3_CHANNELS, st_ivas->hEncoderConfig->input_Fs ) ) != IVAS_ERR_OK )
+ {
+ return error;
+ }
+ }
+#endif
}
else if ( ivas_format == MASA_ISM_FORMAT )
{
@@ -774,6 +796,14 @@ ivas_error ivas_init_encoder(
{
return error;
}
+
+#ifdef NONBE_FIX_1165_APPLY_LIMITER_ON_ENCODER_DMX
+
+ if ( ( error = ivas_limiter_open_fx( &st_ivas->hLimiter, CPE_CHANNELS, st_ivas->hEncoderConfig->input_Fs ) ) != IVAS_ERR_OK )
+ {
+ return error;
+ }
+#endif
}
else if ( ivas_format == SBA_ISM_FORMAT )
{
@@ -860,6 +890,13 @@ ivas_error ivas_init_encoder(
{
return error;
}
+#ifdef NONBE_FIX_1165_APPLY_LIMITER_ON_ENCODER_DMX
+
+ if ( ( error = ivas_limiter_open_fx( &st_ivas->hLimiter, FOA_CHANNELS, st_ivas->hEncoderConfig->input_Fs ) ) != IVAS_ERR_OK )
+ {
+ return error;
+ }
+#endif
}
else if ( ivas_format == MC_FORMAT )
{
@@ -946,6 +983,13 @@ ivas_error ivas_init_encoder(
return error;
}
}
+#ifdef NONBE_FIX_1165_APPLY_LIMITER_ON_ENCODER_DMX
+
+ if ( ( error = ivas_limiter_open_fx( &st_ivas->hLimiter, PARAM_MC_MAX_TRANSPORT_CHANS, st_ivas->hEncoderConfig->input_Fs ) ) != IVAS_ERR_OK )
+ {
+ return error;
+ }
+#endif
}
else if ( st_ivas->mc_mode == MC_MODE_MCMASA )
{
@@ -990,6 +1034,13 @@ ivas_error ivas_init_encoder(
return error;
}
}
+#ifdef NONBE_FIX_1165_APPLY_LIMITER_ON_ENCODER_DMX
+
+ if ( ( error = ivas_limiter_open_fx( &st_ivas->hLimiter, CPE_CHANNELS + 1, st_ivas->hEncoderConfig->input_Fs ) ) != IVAS_ERR_OK )
+ {
+ return error;
+ }
+#endif
}
}
diff --git a/lib_enc/ivas_mc_param_enc.c b/lib_enc/ivas_mc_param_enc.c
index 26a81c1330a574838d052a3e393cbe2297d5564d..e8ee899292bf2ddcfbf5d1f1660ee0eda385fe91 100644
--- a/lib_enc/ivas_mc_param_enc.c
+++ b/lib_enc/ivas_mc_param_enc.c
@@ -148,7 +148,10 @@ ivas_error ivas_param_mc_enc_open_fx(
/* get dmx factors */
hParamMC->dmx_factors_fx = ivas_param_mc_conf[config_index].dmx_fac_fx;
-
+#ifdef NONBE_FIX_1165_STATIC_SCAL_PARAMMC
+ hParamMC->static_dmx_fac_inv_fx = ivas_param_mc_conf[config_index].static_dmx_fac_inv_fx;
+ move32();
+#endif
/* set FB config. */
IF( NE_32( ( error = ivas_fb_set_cfg( &fb_cfg, MC_FORMAT, nchan_inp, 0, 0, input_Fs, 0 ) ), IVAS_ERR_OK ) )
{
@@ -293,6 +296,10 @@ ivas_error ivas_param_mc_enc_reconfig_fx(
/* get dmx factors */
hParamMC->dmx_factors_fx = ivas_param_mc_conf[config_index].dmx_fac_fx;
+#ifdef NONBE_FIX_1165_STATIC_SCAL_PARAMMC
+ hParamMC->static_dmx_fac_inv_fx = ivas_param_mc_conf[config_index].static_dmx_fac_inv_fx;
+ move32();
+#endif
/* open/init parameter coding */
ivas_param_mc_metadata_open_fx( mc_input_setup, ivas_total_brate, &hParamMC->hMetadataPMC );
@@ -609,6 +616,12 @@ static void ivas_param_mc_dmx_fx(
( *dmx_sample_fx ) = Madd_32_32( ( *dmx_sample_fx ), data_f_fx[idx[inp_ch]][i], ( *( p_dmx_fac_fx++ ) ) );
move16();
}
+#ifdef NONBE_FIX_1165_STATIC_SCAL_PARAMMC
+
+ /* Apply scaling gain to prevent clipping of downmix signals */
+ *dmx_sample_fx = Mpy_32_32( *dmx_sample_fx, hParamMC->static_dmx_fac_inv_fx );
+ move32();
+#endif
}
}
diff --git a/lib_enc/ivas_mc_paramupmix_enc.c b/lib_enc/ivas_mc_paramupmix_enc.c
index 4c454a67b6126aef2836dc08a17363155a2da981..e51703ea359608ca3a18edf3a73ed76816b56a47 100644
--- a/lib_enc/ivas_mc_paramupmix_enc.c
+++ b/lib_enc/ivas_mc_paramupmix_enc.c
@@ -809,13 +809,18 @@ static ivas_error ivas_mc_paramupmix_param_est_enc_fx(
move16();
move16();
move16();
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
FOR( i = 0; i < MC_PARAMUPMIX_COMBINATIONS; i++ )
{
pcm_in_fx[2 * i] = data_f_fx[chan1s[i]];
pcm_in_fx[2 * i + 1] = data_f_fx[chan2s[i]];
- move16();
- move16();
Scale_sig32( pcm_in_fx[2 * i], input_frame, sub( Q14, Q_data_f ) );
Scale_sig32( pcm_in_fx[2 * i + 1], input_frame, sub( Q14, Q_data_f ) );
@@ -842,8 +847,6 @@ static ivas_error ivas_mc_paramupmix_param_est_enc_fx(
{
p_fr_realbuffer_fx[i] = fr_realbuffer_fx[i];
p_fr_imagbuffer_fx[i] = fr_imagbuffer_fx[i];
- move32();
- move32();
}
/* prepare Parameter MDFT analysis */
@@ -851,8 +854,6 @@ static ivas_error ivas_mc_paramupmix_param_est_enc_fx(
{
pp_in_fr_real_fx[i] = p_fr_realbuffer_fx[i];
pp_in_fr_imag_fx[i] = p_fr_imagbuffer_fx[i];
- move32();
- move32();
}
// l_ts = input_frame / MAX_PARAM_SPATIAL_SUBFRAMES;
@@ -887,8 +888,8 @@ static ivas_error ivas_mc_paramupmix_param_est_enc_fx(
FOR( i = 0; i < MC_PARAMUPMIX_COMBINATIONS; i++ )
{
- Scale_sig32( pcm_in_fx[2 * i], input_frame, Q_data_f - Q14 );
- Scale_sig32( pcm_in_fx[2 * i + 1], input_frame, Q_data_f - Q14 );
+ Scale_sig32( pcm_in_fx[2 * i], input_frame, sub( Q_data_f, Q14 ) );
+ Scale_sig32( pcm_in_fx[2 * i + 1], input_frame, sub( Q_data_f, Q14 ) );
}
/*-----------------------------------------------------------------------------------------*
@@ -953,15 +954,14 @@ static ivas_error ivas_mc_paramupmix_param_est_enc_fx(
FOR( bnd = 0; bnd < maxbands; bnd++ )
{
rxy_fx = hMCParamUpmix->cov_real_fx[b][1][0][bnd];
+ move32();
ryy_fx = hMCParamUpmix->cov_real_fx[b][1][1][bnd];
+ move32();
- Word16 exp_tmp = 0;
- move16();
- Word32 tmp = BASOP_Util_Add_Mant32Exp( ryy_fx, sub( 31, ( hMCParamUpmix->hCovEnc[b]->pCov_state->q_cov_real_per_band[1][1][bnd] ) ), EPSILON_FX_M, EPSILON_FX_E, &exp_tmp );
exp_cmat = 0;
move16();
- cmat_fx = BASOP_Util_Divide3232_Scale( rxy_fx, tmp, &exp_cmat );
- exp_cmat = sub( add( exp_cmat, sub( 31, ( hMCParamUpmix->hCovEnc[b]->pCov_state->q_cov_real_per_band[1][0][bnd] ) ) ), exp_tmp );
+ cmat_fx = BASOP_Util_Divide3232_Scale( rxy_fx, L_add( ryy_fx, EPSILON_FX ), &exp_cmat );
+ exp_cmat = sub( add( exp_cmat, sub( 31, ( hMCParamUpmix->hCovEnc[b]->pCov_state->q_cov_real_per_band[1][0][bnd] ) ) ), sub( 31, ( hMCParamUpmix->hCovEnc[b]->pCov_state->q_cov_real_per_band[1][1][bnd] ) ) );
Word16 alpha_fx = 0, exp_alpha_var = 0;
move16();
@@ -969,6 +969,7 @@ static ivas_error ivas_mc_paramupmix_param_est_enc_fx(
exp_alpha_var = BASOP_Util_Add_MantExp( cmat_fx, add( exp_cmat, 1 ), negate( ONE_IN_Q14 ), 1, &alpha_fx );
rxx_fx = hMCParamUpmix->cov_real_fx[b][0][0][bnd];
+ move32();
Word32 tmp_2 = L_mult( cmat_fx, cmat_fx ); // exp_cmat * 2
rxxest_fx = Mpy_32_32( tmp_2, ryy_fx );
@@ -980,8 +981,8 @@ static ivas_error ivas_mc_paramupmix_param_est_enc_fx(
exp_wetaux = 0;
move16();
- wetaux_fx = BASOP_Util_Divide3232_Scale( drxx_fx, tmp, &exp_wetaux );
- exp_wetaux = sub( add( exp_wetaux, exp_drxx ), exp_tmp );
+ wetaux_fx = BASOP_Util_Divide3232_Scale( drxx_fx, L_add( ryy_fx, EPSILON_FX ), &exp_wetaux );
+ exp_wetaux = sub( add( exp_wetaux, exp_drxx ), sub( 31, ( hMCParamUpmix->hCovEnc[b]->pCov_state->q_cov_real_per_band[1][1][bnd] ) ) );
Word16 sqrt_wetaux_fx = 0, exp_sqrt_wetaux = 0;
move16();
@@ -993,10 +994,6 @@ static ivas_error ivas_mc_paramupmix_param_est_enc_fx(
move16();
move16();
BASOP_Util_Sqrt_InvSqrt_MantExp( wetaux_fx, exp_wetaux, &sqrt_wetaux_fx, &exp_sqrt_wetaux, &tmp_4, &exp_tmp4 );
- tmp_4 = tmp_4;
- exp_tmp4 = exp_tmp4;
- move16();
- move16();
}
ELSE
{
diff --git a/lib_enc/ivas_mcmasa_enc.c b/lib_enc/ivas_mcmasa_enc.c
index b2be23e73418436b4c9d7a0bc627ad6cb8ab7bed..096317789563a57a80b848edc95ce93600bfcaed 100644
--- a/lib_enc/ivas_mcmasa_enc.c
+++ b/lib_enc/ivas_mcmasa_enc.c
@@ -101,6 +101,9 @@ static void computeEvenLayout_fx(
static void computeLfeEnergy_fx( MCMASA_ENC_HANDLE hMcMasa, Word32 *data_fx[], const Word16 input_frame, Word16 q_fac );
+#ifdef NONBE_FIX_1165_STATIC_SCAL_MCMASA
+static void ivas_mcmasa_gain_dmx_fx( MCMASA_ENC_HANDLE hMcMasa, Word32 *data_f[], const Word16 input_frame, const Word16 nchan_transport, const MC_LS_SETUP mc_ls_setup );
+#endif
/*--------------------------------------------------------------------------*
* ivas_mcmasa_enc_open()
@@ -713,7 +716,7 @@ void ivas_mcmasa_enc_fx(
/* Determine LFE-to-total energy ratio */
FOR( i = 0; i < MAX_PARAM_SPATIAL_SUBFRAMES; i++ )
{
- hMasa->data.lfeToTotalEnergyRatio_fx[i] = BASOP_Util_Divide3232_Scale( hMcMasa->lfeLfEne[i], L_add( EPSILON_FX, hMcMasa->totalLfEne[i] ), &hMasa->data.lfeToTotalEnergyRatio_e[i] );
+ hMasa->data.lfeToTotalEnergyRatio_fx[i] = L_deposit_h( BASOP_Util_Divide3232_Scale( hMcMasa->lfeLfEne[i], L_add( EPSILON_FX, hMcMasa->totalLfEne[i] ), &hMasa->data.lfeToTotalEnergyRatio_e[i] ) );
hMasa->data.lfeToTotalEnergyRatio_e[i] = add( sub( hMcMasa->lfeLfEne_e[i], hMcMasa->totalLfEne_e[i] ), hMasa->data.lfeToTotalEnergyRatio_e[i] );
move32();
move16();
@@ -746,7 +749,7 @@ void ivas_mcmasa_enc_fx(
IF( hQMeta->surcoh_band_data != NULL )
{
- hQMeta->q_direction[0].coherence_band_data[i].spread_coherence[j] = (UWord8) round_fx( Mpy_32_32( spreadCoherence_fx[j][i], L_shl( UINT8_MAX, Q16 ) ) ); // Q0
+ hQMeta->q_direction[0].coherence_band_data[i].spread_coherence[j] = (UWord8) round_fx( Mpy_32_32( spreadCoherence_fx[j][i], L_shl( UINT8_MAX, Q17 ) ) ); // Q0
hQMeta->surcoh_band_data[i].surround_coherence[j] = (UWord8) round_fx( Mpy_32_32( surroundingCoherence_fx[k][i], L_shl( UINT8_MAX, Q16 ) ) ); // Q0
move16();
move16();
@@ -789,7 +792,10 @@ void ivas_mcmasa_enc_fx(
/* Put separated channel back to data_f to first empty channel after the transport audio signals for encoding */
Copy32( separatedChannelSignal, data_fx[2], input_frame );
}
-
+#ifdef NONBE_FIX_1165_STATIC_SCAL_MCMASA
+ /* Apply scaling gain to prevent clipping of downmix signals */
+ ivas_mcmasa_gain_dmx_fx( hMcMasa, data_fx, input_frame, nchan_transport, hQMeta->q_direction->cfg.mc_ls_setup );
+#endif
/* Update mcMASA-relevant coding parameters */
/* These are reset to default values as they may be modified during later processing. */
hMasa->config.joinedSubframes = FALSE;
@@ -814,7 +820,7 @@ void ivas_mcmasa_enc_fx(
WHILE( LT_16( j, nBands ) && hQMeta->all_coherence_zero )
{
test();
- IF( GT_32( spreadCoherence_fx[i][j], MASA_COHERENCE_THRESHOLD_FX ) )
+ IF( GT_32( spreadCoherence_fx[i][j], MASA_COHERENCE_THRESHOLD_FX >> 1 ) )
{
hQMeta->all_coherence_zero = 0;
move16();
@@ -877,7 +883,7 @@ void ivas_mcmasa_param_est_enc_fx(
Word32 elevation_m_values_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* o : Estimated elevation Q22 */
Word32 azimuth_m_values_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* o : Estimated azimuth Q22 */
Word32 energyRatio_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* o : Estimated direct-to-total ratio Q31 */
- Word32 spreadCoherence_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* o : Estimated spread coherence Q31 */
+ Word32 spreadCoherence_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* o : Estimated spread coherence Q30 */
Word32 surroundingCoherence_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* o : Estimated surround coherence Q31 */
const Word16 input_frame, /* i : Input frame size */
const Word16 nchan_inp, /* i : Number of input channels */
@@ -1220,8 +1226,12 @@ void ivas_mcmasa_param_est_enc_fx(
hMcMasa->buffer_energy_q[index - 1] = sub( Q31, ref_e );
move16();
- computeDiffuseness_mdft_fx( hMcMasa->buffer_intensity_real_fx, hMcMasa->buffer_energy_fx, num_freq_bands, hMcMasa->no_col_avg_diff, diffuseness_vector_fx, hMcMasa->buffer_intensity_real_q, hMcMasa->buffer_energy_q, out_exp );
-
+ computeDiffuseness_mdft_fx( hMcMasa->buffer_intensity_real_fx, hMcMasa->buffer_energy_fx, num_freq_bands, hMcMasa->no_col_avg_diff, diffuseness_vector_fx, hMcMasa->buffer_intensity_real_q, hMcMasa->buffer_energy_q, &out_exp[0] );
+ FOR( i = 1; i < num_freq_bands; i++ )
+ {
+ out_exp[i] = out_exp[0];
+ move16();
+ }
/* Compute vertical diffuseness, and tune original diffuseness if needed */
IF( !hMcMasa->isHorizontalSetup )
{
@@ -1243,9 +1253,9 @@ void ivas_mcmasa_param_est_enc_fx(
move32();
IF( hMcMasa->combineRatios )
{
- diffuseness_m_fx[0][band_m_idx] = BASOP_Util_Add_Mant32Exp( diffuseness_m_fx[0][band_m_idx], diffuseness_e[0][band_m_idx], Mult_32_32( reference_power_fx[ts][band_m_idx], diffuseness_vector_fx[band_m_idx] ), sub( 31, sub( shl( inp_q, 1 ), 31 ) ), &diffuseness_e[0][band_m_idx] );
+ diffuseness_m_fx[0][band_m_idx] = BASOP_Util_Add_Mant32Exp( diffuseness_m_fx[0][band_m_idx], diffuseness_e[0][band_m_idx], Mult_32_32( reference_power_fx[ts][band_m_idx], diffuseness_vector_fx[band_m_idx] ), ref_e, &diffuseness_e[0][band_m_idx] );
move32();
- renormalization_factor_diff_fx[band_m_idx] = BASOP_Util_Add_Mant32Exp( renormalization_factor_diff_fx[band_m_idx], renormalization_factor_diff_e[band_m_idx], reference_power_fx[ts][band_m_idx], sub( 31, sub( shl( inp_q, 1 ), 31 ) ), &renormalization_factor_diff_e[band_m_idx] );
+ renormalization_factor_diff_fx[band_m_idx] = BASOP_Util_Add_Mant32Exp( renormalization_factor_diff_fx[band_m_idx], renormalization_factor_diff_e[band_m_idx], reference_power_fx[ts][band_m_idx], ref_e, &renormalization_factor_diff_e[band_m_idx] );
move32();
}
ELSE
@@ -1458,11 +1468,11 @@ void ivas_mcmasa_param_est_enc_fx(
cohPanCoh_e = tempCoh2_e;
move16();
}
- IF( GT_32( cohPanCoh_fx, ONE_IN_Q30 ) )
- {
- cohPanCoh_fx = ONE_IN_Q30;
- move32();
- }
+ /* IF( GT_32( cohPanCoh_fx, ONE_IN_Q30 ) )
+ {
+ cohPanCoh_fx = ONE_IN_Q30;
+ move32();
+ }*/
cohPanCoh_fx = L_shl_sat( cohPanCoh_fx, cohPanCoh_e ); /*Q31*/
cohPanCoh_e = 0;
move16();
@@ -1557,7 +1567,7 @@ void ivas_mcmasa_param_est_enc_fx(
spreadCoh_fx = 0;
move32();
}
- spreadCoh_fx = L_shl( spreadCoh_fx, spreadCoh_e ); /*Q31*/
+ spreadCoh_fx = L_shl( spreadCoh_fx, sub( spreadCoh_e, 1 ) ); /*Q30*/
/* Compute energy ratio tuning parameter */
lsEnergySum_fx = 0;
@@ -1617,7 +1627,7 @@ void ivas_mcmasa_param_est_enc_fx(
}
/* Store values */
- spreadCoherence_fx[block_m_idx][band_m_idx] = spreadCoh_fx; /*Q31*/
+ spreadCoherence_fx[block_m_idx][band_m_idx] = spreadCoh_fx; /*Q30*/
move32();
IF( hMcMasa->combineRatios )
@@ -1961,6 +1971,95 @@ static void ivas_mcmasa_dmx_fx(
return;
}
+
+#ifdef NONBE_FIX_1165_STATIC_SCAL_MCMASA
+/* Gain downmix signals to prevent clipping */
+static void ivas_mcmasa_gain_dmx_fx(
+ MCMASA_ENC_HANDLE hMcMasa,
+ Word32 *data_f[], // Qx
+ const Word16 input_frame,
+ const Word16 nchan_transport,
+ const MC_LS_SETUP mc_ls_setup )
+{
+ Word32 gain;
+
+ gain = MAX_32;
+ move32();
+
+ IF( hMcMasa->separateChannelEnabled )
+ {
+ /* Separate channel gaining */
+ v_multc_fixed( data_f[2], ivas_mcmasa_dmx_scal_fac_sep_chan_static_inv_FX_IN_Q31, data_f[2], input_frame );
+
+ /* Downmix channels gaining */
+ IF( EQ_16( mc_ls_setup, MC_LS_SETUP_5_1_4 ) )
+ {
+ gain = ivas_mcmasa_dmx_scal_fac_CICP16_3tc_static_inv_FX_IN_Q31;
+ move32();
+ }
+ ELSE IF( EQ_16( mc_ls_setup, MC_LS_SETUP_7_1_4 ) )
+ {
+ gain = ivas_mcmasa_dmx_scal_fac_CICP19_3tc_static_inv_FX_IN_Q31;
+ move32();
+ }
+
+ v_multc_fixed( data_f[0], gain, data_f[0], input_frame );
+ v_multc_fixed( data_f[1], gain, data_f[1], input_frame );
+ }
+ ELSE
+ {
+ IF( EQ_16( nchan_transport, 2 ) )
+ {
+ IF( EQ_16( mc_ls_setup, MC_LS_SETUP_5_1_4 ) )
+ {
+ gain = ivas_mcmasa_dmx_scal_fac_CICP16_2tc_static_inv_FX_IN_Q31;
+ move32();
+ }
+ ELSE IF( EQ_16( mc_ls_setup, MC_LS_SETUP_7_1_4 ) )
+ {
+ gain = ivas_mcmasa_dmx_scal_fac_CICP19_2tc_static_inv_FX_IN_Q31;
+ move32();
+ }
+
+ v_multc_fixed( data_f[0], gain, data_f[0], input_frame );
+ v_multc_fixed( data_f[1], gain, data_f[1], input_frame );
+ }
+ ELSE
+ {
+ IF( EQ_16( mc_ls_setup, MC_LS_SETUP_5_1 ) )
+ {
+ gain = ivas_mcmasa_dmx_scal_fac_CICP6_1tc_static_inv_FX_IN_Q31;
+ move32();
+ }
+ ELSE IF( EQ_16( mc_ls_setup, MC_LS_SETUP_7_1 ) )
+ {
+ gain = ivas_mcmasa_dmx_scal_fac_CICP12_1tc_static_inv_FX_IN_Q31;
+ move32();
+ }
+ ELSE IF( EQ_16( mc_ls_setup, MC_LS_SETUP_5_1_2 ) )
+ {
+ gain = ivas_mcmasa_dmx_scal_fac_CICP14_1tc_static_inv_FX_IN_Q31;
+ move32();
+ }
+ ELSE IF( EQ_16( mc_ls_setup, MC_LS_SETUP_5_1_4 ) )
+ {
+ gain = ivas_mcmasa_dmx_scal_fac_CICP16_1tc_static_inv_FX_IN_Q31;
+ move32();
+ }
+ ELSE IF( EQ_16( mc_ls_setup, MC_LS_SETUP_7_1_4 ) )
+ {
+ gain = ivas_mcmasa_dmx_scal_fac_CICP19_1tc_static_inv_FX_IN_Q31;
+ move32();
+ }
+
+ v_multc_fixed( data_f[0], gain, data_f[0], input_frame );
+ }
+ }
+
+ return;
+}
+#endif
+
/* Compute covariance matrix, i.e., xT * conj(x), and accumulate to the output */
static void compute_cov_mtx_fx(
Word32 sr[MCMASA_MAX_ANA_CHANS][DIRAC_NO_FB_BANDS_MAX], /* i : Input matrix, real, s[ch][freq] (inp_exp) */
diff --git a/lib_enc/ivas_omasa_enc.c b/lib_enc/ivas_omasa_enc.c
index 750db361656d286e532e28ff776d6362bbae1646..2160685cbb6942ea086aeb7b61e9b4ff4f4e2799 100644
--- a/lib_enc/ivas_omasa_enc.c
+++ b/lib_enc/ivas_omasa_enc.c
@@ -66,6 +66,9 @@ static void ivas_omasa_param_est_enc_fx(
Word16 q_data /*i: Qfactor for data*/
);
+#ifdef NONBE_FIX_1165_STATIC_SCAL_OMASA
+static void ivas_omasa_gain_dmx_fx( ISM_MODE ism_mode, Word32 *data_f[], const Word16 nchan_transport, const Word16 nchan_ism, const Word16 input_frame );
+#endif
static void ivas_omasa_energy_and_ratio_est_fx(
OMASA_ENC_HANDLE hOMasa,
OMASA_ENCODER_DATA_HANDLE hOmasaData,
@@ -764,7 +767,11 @@ void ivas_omasa_enc_fx(
/* Merge transport signals */
ivas_merge_masa_transports_fx( data_out, &( data_in[nchan_ism] ), data_in, input_frame, nchan_transport );
+#ifdef NONBE_FIX_1165_STATIC_SCAL_OMASA
+ /* Apply scaling gain to prevent clipping of downmix signals */
+ ivas_omasa_gain_dmx_fx( ism_mode, data_in, nchan_transport, nchan_ism, input_frame );
+#endif
return;
}
@@ -1582,3 +1589,76 @@ static void computeReferencePower_omasa_ivas_fx(
move16();
return;
}
+
+#ifdef NONBE_FIX_1165_STATIC_SCAL_OMASA
+/* Gain downmix signals to prevent clipping */
+static void ivas_omasa_gain_dmx_fx(
+ ISM_MODE ism_mode,
+ Word32 *data_f[], // Qx
+ const Word16 nchan_transport,
+ const Word16 nchan_ism,
+ const Word16 input_frame )
+{
+ Word16 ch;
+ Word32 gain;
+
+ gain = MAX_32;
+ move32();
+ test();
+ IF( EQ_16( ism_mode, ISM_MODE_NONE ) )
+ {
+ /* Full downmix mode. */
+ IF( EQ_16( nchan_ism, 1 ) )
+ {
+ gain = ivas_omasa_dmx_scal_fac_2ch_static_inv_FX_IN_Q31;
+ move32();
+ }
+ ELSE IF( EQ_16( nchan_ism, 2 ) )
+ {
+ gain = ivas_omasa_dmx_scal_fac_3ch_static_inv_FX_IN_Q31;
+ move32();
+ }
+ ELSE IF( EQ_16( nchan_ism, 3 ) )
+ {
+ gain = ivas_omasa_dmx_scal_fac_4ch_static_inv_FX_IN_Q31;
+ move32();
+ }
+ ELSE IF( EQ_16( nchan_ism, 4 ) )
+ {
+ gain = ivas_omasa_dmx_scal_fac_5ch_static_inv_FX_IN_Q31;
+ move32();
+ }
+ }
+ ELSE IF( EQ_16( ism_mode, ISM_MASA_MODE_MASA_ONE_OBJ ) || EQ_16( ism_mode, ISM_MASA_MODE_PARAM_ONE_OBJ ) )
+ {
+ /* One separated object + downmix mode. */
+ IF( EQ_16( nchan_ism, 2 ) )
+ {
+ gain = ivas_omasa_dmx_scal_fac_2ch_static_inv_FX_IN_Q31;
+ move32();
+ }
+ ELSE IF( EQ_16( nchan_ism, 3 ) )
+ {
+ gain = ivas_omasa_dmx_scal_fac_3ch_static_inv_FX_IN_Q31;
+ move32();
+ }
+ ELSE IF( EQ_16( nchan_ism, 4 ) )
+ {
+ gain = ivas_omasa_dmx_scal_fac_4ch_static_inv_FX_IN_Q31;
+ move32();
+ }
+ }
+ ELSE
+ {
+ /* Skip gain */
+ return;
+ }
+
+ FOR( ch = 0; ch < nchan_transport; ch++ )
+ {
+ v_multc_fixed( data_f[ch], gain, data_f[ch], input_frame );
+ }
+
+ return;
+}
+#endif
diff --git a/lib_enc/ivas_osba_enc.c b/lib_enc/ivas_osba_enc.c
index f018f250a9f7e980b6db552c8a5b639278879213..2ed9a3c65c1438e5204a1947660963a1e9552ff5 100644
--- a/lib_enc/ivas_osba_enc.c
+++ b/lib_enc/ivas_osba_enc.c
@@ -79,12 +79,17 @@ static void ivas_merge_sba_transports_fx(
{
FOR( j = 0; j < input_frame; j++ )
{
+#ifdef NONBE_FIX_1165_STATIC_SCAL_OSBA_PREREND
+ data_out_f[i][j] = L_shr( L_add( L_shr( data_in_f1[i][j], 1 ), L_shr( data_in_f2[i][j], sub( Q_f2, sub( Q_f1, 1 ) ) ) ), 2 );
+#else
#ifdef NONE_BE_FIX_BASOP_1044_OSBA_PRERENDER_MIX_GAINS
data_out_f[i][j] = L_shr( L_add( L_shr( data_in_f1[i][j], 1 ), L_shr( data_in_f2[i][j], sub( Q_f2, sub( Q_f1, 1 ) ) ) ), Q1 );
+ move32();
#else
data_out_f[i][j] = L_add( L_shr( data_in_f1[i][j], 1 ), L_shr( data_in_f2[i][j], sub( Q_f2, sub( Q_f1, 1 ) ) ) );
#endif
move32();
+#endif
}
}
*Q_out = sub( Q_f1, 1 );
diff --git a/lib_enc/ivas_stat_enc.h b/lib_enc/ivas_stat_enc.h
index e9b06d77df8844c24b5fc3cffad5f54006ebbbbc..8e009a9a89672a50e9079de4b70b671d442891f1 100644
--- a/lib_enc/ivas_stat_enc.h
+++ b/lib_enc/ivas_stat_enc.h
@@ -806,7 +806,7 @@ typedef struct ivas_param_mc_enc_data_structure
IVAS_FB_MIXER_HANDLE hFbMixer;
Word16 transient_detector_delay;
const Word32 *dmx_factors_fx; /* Q31 */
-
+ Word32 static_dmx_fac_inv_fx;
/* Multichannel Specific Parameters */
IVAS_PARAM_MC_METADATA hMetadataPMC;
Word16 band_grouping[PARAM_MC_MAX_PARAMETER_BANDS + 1];
@@ -1337,6 +1337,13 @@ typedef struct
SCE_ENC_HANDLE hSCE[MAX_SCE]; /* SCE handles */
CPE_ENC_HANDLE hCPE[MCT_MAX_BLOCKS]; /* CPE handles */
+#ifdef NONBE_FIX_1165_APPLY_LIMITER_ON_ENCODER_DMX
+
+ IVAS_LIMITER_HANDLE hLimiter; /* Limiter handle */
+#endif
+#ifdef DEBUGGING
+ int32_t noClipping; /* number of clipped samples */
+#endif
/* multichannel modules */
ISM_METADATA_HANDLE hIsmMetaData[MAX_NUM_OBJECTS]; /* ISM metadata handles (storage for one frame of read ISM metadata) */
ISM_DTX_HANDLE hISMDTX; /* ISM DTX handle */
diff --git a/lib_enc/multi_harm_fx.c b/lib_enc/multi_harm_fx.c
index 03b8357529b34dd7388bf7aef7eb89fc78059406..92666570c892508d994b40f50663f7fa1ded24c7 100644
--- a/lib_enc/multi_harm_fx.c
+++ b/lib_enc/multi_harm_fx.c
@@ -375,3 +375,353 @@ Word16 multi_harm_fx( /* o : frame multi-harmonicity
}
return harm;
}
+
+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 : input 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 i, j, k, L, stemp, N_mins, ind_mins[L_FFT / 4], *pt_mins, harm;
+ Word16 S[L_FFT / 2], flor, step, tmp16, tmp2, Expx2, Expy2;
+ Word16 corx2, cory2, corxy, cor, cor_map[L_FFT / 2], *pt1, *pt2, cor_strong;
+ Word32 L_acc;
+ Word32 Lcorx2, Lcory2, Lcorxy, Lcor_map_LT_sum;
+ Word16 mean_dyn;
+#ifdef BASOP_NOGLOB_DECLARE_LOCAL
+ Flag Overflow = 0;
+ move32();
+#endif
+
+ /*------------------------------------------------------------------*
+ * initialization
+ *------------------------------------------------------------------*/
+
+ /* length of the useful part of the spectrum (up to 6.4kHz) */
+ L = L_FFT / 2;
+ move16();
+ if ( EQ_16( bwidth, NB ) )
+ {
+ /* length of the useful part of the spectrum (up to 3.6kHz) */
+ L = 76;
+ move16();
+ }
+
+ Copy( Bin_E, S, L );
+
+ /*------------------------------------------------------------------*
+ * searching of spectral maxima and minima
+ *------------------------------------------------------------------*/
+
+ pt_mins = ind_mins;
+
+ /* index of the first minimum */
+ if ( LT_16( Bin_E[0], Bin_E[1] ) )
+ {
+ *pt_mins++ = 0;
+ move16();
+ }
+
+ FOR( i = 1; i < L - 1; i++ )
+ {
+ /* minimum found */
+ test();
+ if ( LT_16( Bin_E[i], Bin_E[i - 1] ) && LT_16( Bin_E[i], Bin_E[i + 1] ) )
+ {
+ *pt_mins++ = i;
+ move16();
+ }
+ }
+
+ /* index of the last minimum */
+ IF( LT_16( Bin_E[L - 1], Bin_E[L - 2] ) )
+ {
+ *pt_mins++ = sub( L, 1 );
+ move16();
+ }
+
+ /* total number of minimas found */
+ N_mins = (Word16) ( pt_mins - ind_mins - 1 );
+ move16();
+
+ /*------------------------------------------------------------------*
+ * calculation of the spectral floor
+ * subtraction of the spectral floor
+ *------------------------------------------------------------------*/
+
+ set16_fx( S, 0, L );
+
+ IF( N_mins > 0 )
+ {
+ L_acc = L_deposit_l( 0 );
+ FOR( i = 0; i < N_mins; ++i )
+ {
+ L_acc = L_mac0( L_acc, Bin_E[ind_mins[i]], 1 );
+ }
+ *sp_floor = extract_l( Mult_32_16( L_acc, div_s( 1, N_mins ) ) );
+ move16();
+
+ set16_fx( S, 0, ind_mins[0] );
+ set16_fx( &S[ind_mins[N_mins]], 0, sub( shr( L_FFT, 1 ), ind_mins[N_mins] ) );
+
+ pt_mins = ind_mins;
+ flor = 0;
+ move16();
+ step = 0;
+ move16();
+
+ FOR( i = ind_mins[0]; i < ind_mins[N_mins]; i++ )
+ {
+ /* we are at the end of the next minimum */
+ IF( EQ_16( i, *pt_mins ) )
+ {
+ pt_mins++;
+ flor = Bin_E[i];
+ move16(); /*Q7*/
+
+ /* calculate the new step */
+ /*step = (Bin_E[*pt_mins] - Bin_E[i]) / (*pt_mins-i);*/
+
+ tmp16 = div_s( 1, sub( *pt_mins, i ) ); // Q15
+ step = msu_r( L_mult( Bin_E[*pt_mins], tmp16 ), Bin_E[i], tmp16 ); // Q7 (15+7+1-16)
+ }
+
+ /* subtract the floor */
+ S[i] = s_max( sub_sat( Bin_E[i], flor ), 0 );
+ move16();
+
+ /* update the floor */
+ flor = add( flor, step ); /*Q7*/
+ }
+ }
+
+ /* Calculate the maximum dynamic per band */
+ /* since we are processing 40 bins we will use 1/40 in Q15 to find the mean */
+ /* mean_dyn = mean(&S[L-40], 40);*/
+ L_acc = L_deposit_l( 0 );
+ FOR( i = L - 40; i < L; i++ )
+ {
+ L_acc = L_mac( L_acc, S[i], 819 /* 1 / 40 in Q15 */ );
+ }
+ mean_dyn = round_fx( L_acc ); /*Q7*/
+
+ /*mean_dyn = 0.6f * *st_mean_avr_dyn + 0.4f * mean_dyn;*/
+ L_acc = L_mult( 13107 /*0.4f*/, mean_dyn ); /*Q23*/
+ L_acc = L_mac( L_acc, 19661 /*0.6f*/, *st_mean_avr_dyn ); /*Q23*/
+ mean_dyn = round_fx( L_acc ); /*Q7*/
+
+ test();
+ IF( LT_16( mean_dyn, 1229 ) /*9.6f*/ && *cor_strong_limit != 0 )
+ {
+ *cor_strong_limit = 0;
+ move16();
+ *st_last_sw_dyn = mean_dyn;
+ move16();
+ }
+ ELSE IF( GT_16( sub( mean_dyn, *st_last_sw_dyn ), 576 ) /*4.5f*/ )
+ {
+ *cor_strong_limit = 1;
+ move16();
+ }
+ test();
+ if ( LT_32( total_brate, ACELP_9k60 ) || GT_32( total_brate, ACELP_16k40 ) )
+ {
+ *cor_strong_limit = 1;
+ move16();
+ }
+
+ *st_mean_avr_dyn = mean_dyn;
+ move16();
+
+ /*------------------------------------------------------------------*
+ * calculation of the correlation map
+ *------------------------------------------------------------------*/
+
+ set16_fx( cor_map, 0, L );
+ IF( N_mins > 0 )
+ {
+ Lcorx2 = L_deposit_l( 0 );
+ Lcorxy = L_deposit_l( 0 );
+ stemp = ind_mins[0];
+ move16();
+ Lcory2 = L_mult( old_S[stemp], old_S[stemp] );
+ k = 1;
+ move16();
+
+ FOR( i = add( stemp, 1 ); i <= ind_mins[N_mins]; i++ )
+ {
+ IF( EQ_16( i, ind_mins[k] ) )
+ {
+ /* include the last peak point (new minimum) to the corr. sum */
+#ifdef BASOP_NOGLOB
+ Lcory2 = L_mac_o( Lcory2, old_S[i], old_S[i], &Overflow );
+#else /* BASOP_NOGLOB */
+ Lcory2 = L_mac( Lcory2, old_S[i], old_S[i] );
+#endif /* BASOP_NOGLOB */
+
+ /* calculation of the norm. peak correlation */
+ test();
+ IF( Lcorx2 != 0 && Lcory2 != 0 )
+ {
+ /* corxy * corxy*/
+ tmp16 = sub( norm_l( Lcorxy ), 1 );
+ corxy = extract_h( L_shl( Lcorxy, tmp16 ) );
+ corxy = mult_r( corxy, corxy );
+ /* (corx2 * cory2) */
+ Expx2 = norm_l( Lcorx2 );
+ Expy2 = norm_l( Lcory2 );
+ corx2 = extract_h( L_shl( Lcorx2, Expx2 ) );
+ cory2 = extract_h( L_shl( Lcory2, Expy2 ) );
+ corx2 = mult_r( corx2, cory2 );
+ Expx2 = add( Expy2, Expx2 );
+ /* Validate num < den */
+ cor = sub( corx2, corxy );
+ cor = shr( cor, 15 );
+ /* Add 1 to tmp16 & shr by 2 if corxy > corx2 */
+ tmp16 = sub( tmp16, cor );
+ corxy = shl( corxy, cor );
+ corxy = shl( corxy, cor );
+ /* cor = corxy * corxy / (corx2 * cory2) */
+ corxy = div_s( corxy, corx2 );
+#ifdef BASOP_NOGLOB
+ cor = shr_o( corxy, sub( shl( tmp16, 1 ), Expx2 ), &Overflow ); /* Q15 */
+#else /* BASOP_NOGLOB */
+ cor = shr( corxy, sub( shl( tmp16, 1 ), Expx2 ) ); /* Q15 */
+#endif /* BASOP_NOGLOB */
+ }
+ ELSE
+ {
+ cor = 0;
+ move16();
+ }
+
+ /* save the norm. peak correlation in the correlation map */
+ FOR( j = ind_mins[k - 1]; j < ind_mins[k]; j++ )
+ {
+ old_S[j] = S[j];
+ move16();
+ S[j] = shr( cor, 8 );
+ move16();
+ cor_map[j] = cor;
+ move16();
+ }
+
+ Lcorx2 = L_deposit_l( 0 );
+ Lcory2 = L_deposit_l( 0 );
+ Lcorxy = L_deposit_l( 0 );
+
+ k++;
+ }
+#ifdef BASOP_NOGLOB
+ Lcorx2 = L_mac_o( Lcorx2, S[i], S[i], &Overflow );
+ Lcory2 = L_mac_o( Lcory2, old_S[i], old_S[i], &Overflow );
+ Lcorxy = L_mac_o( Lcorxy, S[i], old_S[i], &Overflow );
+#else /* BASOP_NOGLOB */
+ Lcorx2 = L_mac( Lcorx2, S[i], S[i] );
+ Lcory2 = L_mac( Lcory2, old_S[i], old_S[i] );
+ Lcorxy = L_mac( Lcorxy, S[i], old_S[i] );
+#endif
+ }
+
+ Copy( S, old_S, ind_mins[0] );
+ Copy( &S[ind_mins[N_mins]], &old_S[ind_mins[N_mins]], sub( L, ind_mins[N_mins] ) );
+ }
+ ELSE
+ {
+ *sp_floor = Bin_E[0];
+ move16();
+ }
+ *sp_floor = mult( *sp_floor, 14231 /* 1.0f / logf( 10.0f ) in Q15 */ );
+ move16(); /* Convert to log10() */
+
+ /*------------------------------------------------------------------*
+ * updating of the long-term correlation map
+ * summation of the long-term correlation map
+ *------------------------------------------------------------------*/
+
+ Lcor_map_LT_sum = L_deposit_l( 0 );
+ tmp2 = 0;
+ move16();
+
+ cor_strong = 0;
+ move16();
+ pt1 = cor_map_LT;
+ move16();
+ pt2 = cor_map;
+ move16();
+ FOR( i = 0; i < L; i++ )
+ {
+ /* tmp2 += S[i]; */
+ tmp2 = add( tmp2, shl( S[i], 1 ) ); /* tmp2 in Q8; max value is 128) */
+
+ /* *pt1 = M_ALPHA_FX * *pt1 + (1-M_ALPHA_FX) * *pt2++ */
+ *pt1 = mac_r( L_mult( ONE_MINUS_M_ALPHA, *pt2 ), M_ALPHA_FX, *pt1 );
+ move16();
+
+ /* cor_map_LT_sum += *pt1 */
+ Lcor_map_LT_sum = L_add( Lcor_map_LT_sum, *pt1 ); /* cor_map_LT_sum in Q15; max value is 128) */
+
+ if ( GT_16( *pt1, 31130 ) /*0.95f*/ )
+ {
+ cor_strong = 1;
+ move16();
+ }
+
+ pt1++;
+ pt2++;
+ }
+
+ IF( EQ_16( bwidth, NB ) )
+ {
+ /* cor_map_LT_sum *= 1.53f; */
+ /* tmp2 *= 1.53f; */
+ Lcor_map_LT_sum = L_shl( Mult_32_16( Lcor_map_LT_sum, 25068 /* 1.53f in Q14 */ ), 1 );
+ tmp2 = round_fx( L_mac( L_mult( tmp2, 32767 ), tmp2, 17367 /* 0.53 in Q15 */ ) );
+ }
+ *cor_map_sum = tmp2;
+ move16();
+
+ /* final decision about multi-harmonicity */
+ harm = 0;
+ move16();
+ test();
+ if ( ( L_msu0( Lcor_map_LT_sum, *multi_harm_limit, 64 ) > 0 ) || ( cor_strong != 0 ) )
+ {
+ harm = 1;
+ move16();
+ }
+
+ /*------------------------------------------------------------------*
+ * updating of the decision threshold
+ *------------------------------------------------------------------*/
+
+ stemp = add( *multi_harm_limit, THR_CORR_STEP_FX );
+ if ( GT_32( Lcor_map_LT_sum, THR_CORR_FX ) ) /* Q15 */
+ {
+ /* *multi_harm_limit -= THR_CORR_STEP_FX */
+ stemp = sub( *multi_harm_limit, THR_CORR_STEP_FX );
+ }
+
+ stemp = s_min( stemp, THR_CORR_MAX_FX );
+ *multi_harm_limit = s_max( stemp, THR_CORR_MIN_FX );
+ move16();
+
+ IF( N_mins <= 0 )
+ {
+ set16_fx( old_S, 0, L );
+ }
+ IF( S_map != NULL )
+ {
+ Copy( S, S_map, L );
+ }
+ return harm;
+}
diff --git a/lib_enc/nois_est_fx.c b/lib_enc/nois_est_fx.c
index a4958af7444a6f3f0a2ddedb6d63087fc91af418..2b8bded71038a4a6429a3d3c4721f502e5fe4c25 100644
--- a/lib_enc/nois_est_fx.c
+++ b/lib_enc/nois_est_fx.c
@@ -2353,8 +2353,8 @@ void noise_est_ivas_fx(
{
i = 0;
move16();
- *loc_harm = multi_harm_fx( EspecdB, hNoiseEst->old_S_fx, hNoiseEst->cor_map_fx, &hNoiseEst->multi_harm_limit_fx, st_fx->total_brate,
- st_fx->bwidth, ( st_fx->hGSCEnc != NULL ) ? &hGSCEnc->cor_strong_limit : &i, &hSpMusClas->mean_avr_dyn_fx, &hSpMusClas->last_sw_dyn_fx, cor_map_sum, sp_floor, S_map );
+ *loc_harm = multi_harm_ivas_fx( EspecdB, hNoiseEst->old_S_fx, hNoiseEst->cor_map_fx, &hNoiseEst->multi_harm_limit_fx, st_fx->total_brate,
+ st_fx->bwidth, ( st_fx->hGSCEnc != NULL ) ? &hGSCEnc->cor_strong_limit : &i, &hSpMusClas->mean_avr_dyn_fx, &hSpMusClas->last_sw_dyn_fx, cor_map_sum, sp_floor, S_map );
move16();
}
}
diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h
index c8c8aea023cc5d8a44cebbf6226de3dd8f864293..cff02d9111782ac2d48c4d6e550a934184d266c9 100644
--- a/lib_enc/prot_fx_enc.h
+++ b/lib_enc/prot_fx_enc.h
@@ -4449,6 +4449,21 @@ Word16 multi_harm_fx( /* o : frame multi-harmonicity
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 */
+);
+
void pvq_encode_frame_fx(
BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
const Word16 *coefs_norm, /* i : normalized coefficients to encode */
diff --git a/lib_enc/speech_music_classif_fx.c b/lib_enc/speech_music_classif_fx.c
index 54ea16f6f8bef652577d0a504dac206052ed317b..6f8fba9f1e49c0fc7f74d14ca84ab9f1a4522b38 100644
--- a/lib_enc/speech_music_classif_fx.c
+++ b/lib_enc/speech_music_classif_fx.c
@@ -2624,10 +2624,8 @@ Word16 ivas_smc_gmm_fx(
mvs2s( &hSpMusClas->past_dec[0], &hSpMusClas->past_dec[1], HANG_LEN - 2 );
hSpMusClas->past_dec[0] = dec;
move16();
-#ifndef IVAS_FLOAT_FIXED
#ifdef DEBUG_MODE_INFO
dbgwrite( &st->hSpMusClas->wdlp_0_95_sp_32fx, sizeof( Word32 ), 1, 1, "res/wdlp_0_95_sp.x" );
-#endif
#endif
return dec;
diff --git a/lib_enc/tns_base_enc_fx.c b/lib_enc/tns_base_enc_fx.c
index 4d715dc3cd897558969e1c85d06cae23eb5d0485..9790bbae23e59b711aff1559f789e2d700f3eb1f 100644
--- a/lib_enc/tns_base_enc_fx.c
+++ b/lib_enc/tns_base_enc_fx.c
@@ -690,7 +690,7 @@ Word16 DetectTnsFilt_ivas_fx( STnsConfig const *pTnsConfig, /* i : TNS Configur
pWindow = tnsAcfWindow_fx;
n = sub( iEndLine, iStartLine );
- assert( n < (Word16) ( sizeof( tmpbuf ) / sizeof( Word16 ) ) );
+ assert( n <= (Word16) ( sizeof( tmpbuf ) / sizeof( Word16 ) ) );
FOR( i = 0; i < n; i++ )
{
tmpbuf[i] = round_fx_sat( L_shl( pSpectrum[iStartLine + i], shift ) ); // using round_fx_sat to address corner case
diff --git a/lib_rend/ivas_prot_rend.h b/lib_rend/ivas_prot_rend.h
index 396b1163a214518338cb8ba5699a79715a5162c4..edafaa39b901d9d040aa3d2403547a4799b633e8 100644
--- a/lib_rend/ivas_prot_rend.h
+++ b/lib_rend/ivas_prot_rend.h
@@ -82,6 +82,7 @@ Word16 ivas_get_nchan_buffers_dec_ivas_fx(
);
/*----------------------------------------------------------------------------------*
+<<<<<<< HEAD
* Limiter prototypes
*----------------------------------------------------------------------------------*/
diff --git a/lib_rend/ivas_rom_rend.c b/lib_rend/ivas_rom_rend.c
index d99a4ad767eb35559af5023fc47d78e116ac07a5..1939dd55e5f9193f5c5be20d0a48712b9aea65c2 100644
--- a/lib_rend/ivas_rom_rend.c
+++ b/lib_rend/ivas_rom_rend.c
@@ -598,825 +598,6 @@ const float ivas_reverb_default_DSR[IVAS_REVERB_DEFAULT_N_BANDS] =
6.2001e-08f, 2.8483e-08f, 2.6267e-08f
};
-const Word32 release_cnst_table[4][201] = // Q31
- {
- {
- 1913946752,
- 1919716352,
- 1925351680,
- 1930855552,
- 1936230784,
- 1941479808,
- 1946605312,
- 1951609728,
- 1956495744,
- 1961265792,
- 1965922304,
- 1970467584,
- 1974904320,
- 1979234560,
- 1983460736,
- 1987585024,
- 1991609856,
- 1995537280,
- 1999369344,
- 2003108480,
- 2006756480,
- 2010315520,
- 2013787520,
- 2017174528,
- 2020478464,
- 2023701248,
- 2026844672,
- 2029910656,
- 2032900992,
- 2035817344,
- 2038661376,
- 2041435008,
- 2044139648,
- 2046777088,
- 2049348864,
- 2051856384,
- 2054301440,
- 2056685312,
- 2059009536,
- 2061275520,
- 2063484672,
- 2065638272,
- 2067737856,
- 2069784448,
- 2071779584,
- 2073724416,
- 2075620096,
- 2077467904,
- 2079268992,
- 2081024512,
- 2082735488,
- 2084403200,
- 2086028416,
- 2087612544,
- 2089156352,
- 2090660864,
- 2092127104,
- 2093555968,
- 2094948480,
- 2096305408,
- 2097627776,
- 2098916352,
- 2100172032,
- 2101395584,
- 2102587776,
- 2103749504,
- 2104881408,
- 2105984384,
- 2107059072,
- 2108106112,
- 2109126400,
- 2110120448,
- 2111088896,
- 2112032512,
- 2112951808,
- 2113847552,
- 2114720128,
- 2115570304,
- 2116398592,
- 2117205504,
- 2117991552,
- 2118757504,
- 2119503616,
- 2120230400,
- 2120938496,
- 2121628288,
- 2122300288,
- 2122954880,
- 2123592576,
- 2124213760,
- 2124818944,
- 2125408384,
- 2125982592,
- 2126541952,
- 2127086848,
- 2127617664,
- 2128134656,
- 2128638336,
- 2129128832,
- 2129606784,
- 2130072192,
- 2130525568,
- 2130967296,
- 2131397376,
- 2131816448,
- 2132224640,
- 2132622080,
- 2133009408,
- 2133386496,
- 2133753856,
- 2134111744,
- 2134460288,
- 2134799744,
- 2135130368,
- 2135452416,
- 2135766144,
- 2136071680,
- 2136369152,
- 2136659072,
- 2136941312,
- 2137216256,
- 2137484160,
- 2137744896,
- 2137998976,
- 2138246400,
- 2138487424,
- 2138722176,
- 2138950656,
- 2139173376,
- 2139390208,
- 2139601408,
- 2139807104,
- 2140007424,
- 2140202624,
- 2140392576,
- 2140577664,
- 2140758016,
- 2140933504,
- 2141104512,
- 2141271040,
- 2141433216,
- 2141591168,
- 2141745024,
- 2141894912,
- 2142040832,
- 2142182912,
- 2142321408,
- 2142456192,
- 2142587392,
- 2142715264,
- 2142839808,
- 2142961152,
- 2143079296,
- 2143194240,
- 2143306240,
- 2143415424,
- 2143521664,
- 2143625216,
- 2143725952,
- 2143824128,
- 2143919744,
- 2144012800,
- 2144103424,
- 2144191744,
- 2144277760,
- 2144361472,
- 2144443136,
- 2144522496,
- 2144599936,
- 2144675200,
- 2144748544,
- 2144820096,
- 2144889600,
- 2144957440,
- 2145023488,
- 2145087744,
- 2145150336,
- 2145211264,
- 2145270656,
- 2145328512,
- 2145384832,
- 2145439616,
- 2145493120,
- 2145545088,
- 2145595776,
- 2145645056,
- 2145693184,
- 2145739904,
- 2145785472,
- 2145829888,
- 2145873152,
- 2145915136,
- 2145956224,
- 2145996032,
- 2146034944,
- 2146072832,
- 2146109696,
- 2146145664,
- 2146180608,
- 2146214656,
- 2146247808,
- },
- {
- 2027355264,
- 2030408704,
- 2033386624,
- 2036290944,
- 2039123328,
- 2041885440,
- 2044578944,
- 2047205376,
- 2049766528,
- 2052263680,
- 2054698496,
- 2057072384,
- 2059387008,
- 2061643520,
- 2063843328,
- 2065987968,
- 2068078720,
- 2070116864,
- 2072103552,
- 2074040192,
- 2075927936,
- 2077767936,
- 2079561472,
- 2081309568,
- 2083013376,
- 2084673920,
- 2086292352,
- 2087869696,
- 2089406976,
- 2090905216,
- 2092365184,
- 2093788032,
- 2095174528,
- 2096525824,
- 2097842432,
- 2099125632,
- 2100375808,
- 2101594240,
- 2102781312,
- 2103938048,
- 2105065216,
- 2106163456,
- 2107233536,
- 2108276096,
- 2109292032,
- 2110281728,
- 2111246080,
- 2112185728,
- 2113101056,
- 2113992960,
- 2114861824,
- 2115708288,
- 2116532992,
- 2117336448,
- 2118119168,
- 2118881792,
- 2119624704,
- 2120348416,
- 2121053440,
- 2121740288,
- 2122409344,
- 2123061120,
- 2123696128,
- 2124314624,
- 2124917120,
- 2125504128,
- 2126075776,
- 2126632832,
- 2127175296,
- 2127703808,
- 2128218624,
- 2128720000,
- 2129208448,
- 2129684352,
- 2130147712,
- 2130599168,
- 2131038976,
- 2131467264,
- 2131884416,
- 2132290816,
- 2132686592,
- 2133072256,
- 2133447680,
- 2133813504,
- 2134169856,
- 2134516864,
- 2134854784,
- 2135184000,
- 2135504640,
- 2135816960,
- 2136121216,
- 2136417536,
- 2136706048,
- 2136987136,
- 2137260928,
- 2137527552,
- 2137787264,
- 2138040192,
- 2138286592,
- 2138526464,
- 2138760192,
- 2138987776,
- 2139209472,
- 2139425408,
- 2139635712,
- 2139840512,
- 2140039936,
- 2140234240,
- 2140423424,
- 2140607744,
- 2140787200,
- 2140962048,
- 2141132288,
- 2141298048,
- 2141459584,
- 2141616896,
- 2141769984,
- 2141919232,
- 2142064512,
- 2142205952,
- 2142343808,
- 2142478080,
- 2142608768,
- 2142736128,
- 2142860032,
- 2142980864,
- 2143098368,
- 2143212928,
- 2143324544,
- 2143433088,
- 2143538944,
- 2143641984,
- 2143742336,
- 2143840000,
- 2143935232,
- 2144027904,
- 2144118144,
- 2144206080,
- 2144291712,
- 2144375168,
- 2144456320,
- 2144535424,
- 2144612480,
- 2144687488,
- 2144760448,
- 2144831616,
- 2144900992,
- 2144968448,
- 2145034112,
- 2145098112,
- 2145160448,
- 2145221248,
- 2145280256,
- 2145337856,
- 2145393920,
- 2145448576,
- 2145501696,
- 2145553536,
- 2145603968,
- 2145653120,
- 2145700992,
- 2145747456,
- 2145792896,
- 2145837056,
- 2145880064,
- 2145922048,
- 2145962880,
- 2146002560,
- 2146041344,
- 2146078976,
- 2146115712,
- 2146151424,
- 2146186240,
- 2146220160,
- 2146253184,
- 2146285312,
- 2146316672,
- 2146347136,
- 2146376832,
- 2146405760,
- 2146433920,
- 2146461440,
- 2146488192,
- 2146514176,
- 2146539520,
- 2146564224,
- 2146588160,
- 2146611584,
- 2146634368,
- 2146656640,
- 2146678272,
- 2146699264,
- 2146719744,
- 2146739712,
- 2146759168,
- 2146778112,
- 2146796544,
- 2146814464,
- 2146832000,
- 2146849024,
- 2146865664,
- },
- {
- 2086555136,
- 2088125824,
- 2089656576,
- 2091148416,
- 2092602240,
- 2094018944,
- 2095399680,
- 2096745088,
- 2098056192,
- 2099333888,
- 2100578816,
- 2101792000,
- 2102974080,
- 2104125824,
- 2105248128,
- 2106341760,
- 2107407232,
- 2108445440,
- 2109456896,
- 2110442496,
- 2111402624,
- 2112338176,
- 2113249664,
- 2114137728,
- 2115002880,
- 2115845760,
- 2116666880,
- 2117466880,
- 2118246272,
- 2119005568,
- 2119745280,
- 2120465920,
- 2121167872,
- 2121851776,
- 2122517888,
- 2123166976,
- 2123799168,
- 2124414976,
- 2125014912,
- 2125599360,
- 2126168704,
- 2126723200,
- 2127263360,
- 2127789568,
- 2128302208,
- 2128801408,
- 2129287808,
- 2129761536,
- 2130222976,
- 2130672512,
- 2131110272,
- 2131536768,
- 2131952128,
- 2132356736,
- 2132750848,
- 2133134720,
- 2133508736,
- 2133872896,
- 2134227584,
- 2134573184,
- 2134909696,
- 2135237504,
- 2135556736,
- 2135867648,
- 2136170624,
- 2136465536,
- 2136752896,
- 2137032832,
- 2137305344,
- 2137570816,
- 2137829376,
- 2138081280,
- 2138326528,
- 2138565504,
- 2138798080,
- 2139024768,
- 2139245440,
- 2139460480,
- 2139669888,
- 2139873792,
- 2140072320,
- 2140265856,
- 2140454144,
- 2140637696,
- 2140816384,
- 2140990464,
- 2141159936,
- 2141325056,
- 2141485824,
- 2141642368,
- 2141794944,
- 2141943424,
- 2142088064,
- 2142228992,
- 2142366208,
- 2142499840,
- 2142630016,
- 2142756736,
- 2142880128,
- 2143000448,
- 2143117440,
- 2143231488,
- 2143342592,
- 2143450752,
- 2143556096,
- 2143658624,
- 2143758592,
- 2143855872,
- 2143950592,
- 2144043008,
- 2144132864,
- 2144220416,
- 2144305664,
- 2144388608,
- 2144469504,
- 2144548224,
- 2144624896,
- 2144699648,
- 2144772352,
- 2144843264,
- 2144912256,
- 2144979328,
- 2145044864,
- 2145108480,
- 2145170560,
- 2145231104,
- 2145289856,
- 2145347200,
- 2145403008,
- 2145457408,
- 2145510400,
- 2145561984,
- 2145612160,
- 2145661056,
- 2145708672,
- 2145755136,
- 2145800192,
- 2145844224,
- 2145887104,
- 2145928832,
- 2145969408,
- 2146008960,
- 2146047616,
- 2146085120,
- 2146121600,
- 2146157184,
- 2146191872,
- 2146225664,
- 2146258560,
- 2146290560,
- 2146321792,
- 2146352128,
- 2146381696,
- 2146410496,
- 2146438528,
- 2146465920,
- 2146492416,
- 2146518400,
- 2146543616,
- 2146568192,
- 2146592128,
- 2146615424,
- 2146638080,
- 2146660224,
- 2146681728,
- 2146702720,
- 2146723072,
- 2146743040,
- 2146762368,
- 2146781184,
- 2146799616,
- 2146817408,
- 2146834816,
- 2146851840,
- 2146868352,
- 2146884352,
- 2146900096,
- 2146915328,
- 2146930176,
- 2146944640,
- 2146958720,
- 2146972416,
- 2146985856,
- 2146998784,
- 2147011456,
- 2147023872,
- 2147035904,
- 2147047552,
- 2147058944,
- 2147070080,
- 2147080832,
- 2147091456,
- 2147101696,
- 2147111680,
- 2147121408,
- 2147130880,
- 2147140096,
- 2147149056,
- 2147157760,
- 2147166336,
- 2147174656,
- },
- {
- 2106670080,
- 2107727232,
- 2108757120,
- 2109760640,
- 2110738432,
- 2111691008,
- 2112619136,
- 2113523328,
- 2114404352,
- 2115262592,
- 2116098816,
- 2116913408,
- 2117707136,
- 2118480256,
- 2119233536,
- 2119967360,
- 2120682240,
- 2121378688,
- 2122057088,
- 2122717952,
- 2123361792,
- 2123988992,
- 2124599936,
- 2125195136,
- 2125774848,
- 2126339584,
- 2126889728,
- 2127425536,
- 2127947520,
- 2128456064,
- 2128951296,
- 2129433856,
- 2129903744,
- 2130361600,
- 2130807424,
- 2131241728,
- 2131664768,
- 2132076928,
- 2132478208,
- 2132869248,
- 2133250048,
- 2133620992,
- 2133982208,
- 2134334080,
- 2134676864,
- 2135010688,
- 2135335936,
- 2135652608,
- 2135961088,
- 2136261504,
- 2136554112,
- 2136839168,
- 2137116800,
- 2137387136,
- 2137650560,
- 2137907072,
- 2138156928,
- 2138400256,
- 2138637184,
- 2138867968,
- 2139092864,
- 2139311744,
- 2139524992,
- 2139732736,
- 2139934976,
- 2140131968,
- 2140323840,
- 2140510720,
- 2140692736,
- 2140870016,
- 2141042688,
- 2141210752,
- 2141374592,
- 2141534080,
- 2141689344,
- 2141840640,
- 2141987968,
- 2142131456,
- 2142271232,
- 2142407424,
- 2142539904,
- 2142669056,
- 2142794752,
- 2142917248,
- 2143036544,
- 2143152640,
- 2143265792,
- 2143375872,
- 2143483264,
- 2143587712,
- 2143689472,
- 2143788544,
- 2143885056,
- 2143979136,
- 2144070656,
- 2144159872,
- 2144246656,
- 2144331264,
- 2144413568,
- 2144493824,
- 2144571904,
- 2144647936,
- 2144722048,
- 2144794240,
- 2144864512,
- 2144932864,
- 2144999552,
- 2145064448,
- 2145127680,
- 2145189248,
- 2145249152,
- 2145307520,
- 2145364480,
- 2145419776,
- 2145473792,
- 2145526272,
- 2145577472,
- 2145627264,
- 2145675776,
- 2145723008,
- 2145768960,
- 2145813760,
- 2145857408,
- 2145899904,
- 2145941376,
- 2145981696,
- 2146020864,
- 2146059136,
- 2146096384,
- 2146132608,
- 2146167936,
- 2146202368,
- 2146235776,
- 2146268416,
- 2146300160,
- 2146331136,
- 2146361216,
- 2146390528,
- 2146419200,
- 2146446976,
- 2146474112,
- 2146500480,
- 2146526208,
- 2146551168,
- 2146575488,
- 2146599296,
- 2146622464,
- 2146644864,
- 2146666880,
- 2146688128,
- 2146708992,
- 2146729216,
- 2146748928,
- 2146768128,
- 2146786816,
- 2146805120,
- 2146822784,
- 2146840064,
- 2146856960,
- 2146873344,
- 2146889216,
- 2146904832,
- 2146919936,
- 2146934656,
- 2146948992,
- 2146962944,
- 2146976640,
- 2146989824,
- 2147002752,
- 2147015296,
- 2147027584,
- 2147039488,
- 2147051136,
- 2147062400,
- 2147073408,
- 2147084160,
- 2147094528,
- 2147104768,
- 2147114624,
- 2147124352,
- 2147133696,
- 2147142912,
- 2147151744,
- 2147160448,
- 2147168896,
- 2147177088,
- 2147185152,
- 2147192960,
- 2147200512,
- 2147207936,
- 2147215104,
- 2147222144,
- 2147229056,
- 2147235712,
- 2147242112,
- 2147248384,
- 2147254656,
- 2147260544,
- 2147266432,
- 2147272064,
- 2147277568,
- },
-
-
- };
-
-
/*----------------------------------------------------------------------------------*
* Renderer SBA & MC enc/dec matrices
*----------------------------------------------------------------------------------*/
diff --git a/lib_rend/ivas_rom_rend.h b/lib_rend/ivas_rom_rend.h
index c80fab8ce40466e4ffaad9811daceea1186b2380..5e9a49c11c095ab3c1ff110a4879ad60416f4073 100644
--- a/lib_rend/ivas_rom_rend.h
+++ b/lib_rend/ivas_rom_rend.h
@@ -125,7 +125,6 @@ extern const float ivas_reverb_default_fc[];
extern const float ivas_reverb_default_RT60[];
extern const float ivas_reverb_default_DSR[];
-extern const Word32 release_cnst_table[4][201]; // Q31
/*----------------------------------------------------------------------------------*
* Renderer SBA & MC enc/dec matrices
diff --git a/lib_rend/ivas_stat_rend.h b/lib_rend/ivas_stat_rend.h
index a911631a406753f4060e94ce004e163caeedae2c..f03a8386f9941cdc10892b5b86b6db4ab921309d 100644
--- a/lib_rend/ivas_stat_rend.h
+++ b/lib_rend/ivas_stat_rend.h
@@ -1394,22 +1394,6 @@ typedef struct ivas_hrtfs_parambin_struct
} HRTFS_PARAMBIN, *HRTFS_PARAMBIN_HANDLE;
-/*----------------------------------------------------------------------------------*
- * Limiter structure
- *----------------------------------------------------------------------------------*/
-typedef struct
-{
- Word16 max_num_channels;
- Word16 num_channels;
- Word32 **channel_ptrs_fx;
- Word32 sampling_rate;
- Word32 gain_fx; /* Q30 */
- Word32 release_heuristic_fx; /* Q30 */
- Word32 attack_constant_fx; /* Q31 */
- Word16 strong_saturation_count;
-
-} IVAS_LIMITER, *IVAS_LIMITER_HANDLE;
-
/*----------------------------------------------------------------------------------*
* Loudspeaker Configuration Conversion structure
*----------------------------------------------------------------------------------*/
@@ -1421,8 +1405,8 @@ typedef struct ivas_LS_setupconversion_struct
Word32 *dmxEnergyPrev_fx[MAX_OUTPUT_CHANNELS];
Word16 sfbOffset[MAX_SFB + 2];
Word16 sfbCnt;
- Word16 te_prev_exp;
- Word16 dmx_prev_exp;
+ Word16 te_prev_exp[MAX_OUTPUT_CHANNELS];
+ Word16 dmx_prev_exp[MAX_OUTPUT_CHANNELS];
} LSSETUP_CONVERSION_STRUCT, *LSSETUP_CONVERSION_HANDLE;
diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c
index 870704de637f34dd82a91f9faa206acd11af0cb9..6ff64694891ee9b3bc8ed53b4e438484685a399e 100644
--- a/lib_rend/lib_rend.c
+++ b/lib_rend/lib_rend.c
@@ -45,7 +45,6 @@
#include "wmc_auto.h"
#include "ivas_rom_com_fx.h"
-#include "ivas_prot_fx.h"
#include "prot_fx.h"
#include "debug.h"
#define float_to_fix( n, factor ) ( round( n * ( 1 << factor ) ) )
@@ -6927,6 +6926,9 @@ static ivas_error renderInputMasa(
{
Scale_sig32( tmpBuffer_buff_fx[ch], L_FRAME48k, sub( Q11, *outAudio.pq_fact ) ); /* Q11 */
}
+
+ scale_sig32( outAudio.data_fx, i_mult( outAudio.config.numChannels, outAudio.config.numSamplesPerChannel ), sub( Q11, *outAudio.pq_fact ) ); /* Q11 */
+
ivas_masa_ext_dirac_render_fx( masaInput->hMasaExtRend, tmpBuffer_fx, num_subframes );
*outAudio.pq_fact = Q11;