diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index f1328069a61e844d5332d37f109a949e6e902e20..75c10b3a01b8d2d5c0dac3c95ed6fe292f28f226 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -195,8 +195,8 @@ stages: - Pop-Location .disable-limiter: &disable-limiter -# automatically enable #define DISABLE_LIMITER in options.h, handling both /**/-comment and //-comment - - sed -i.bak -e "s/\/\*[[:space:]]*\(#define[[:space:]]*DISABLE_LIMITER\)[[:space:]]*\*\//\1/g" ./lib_com/options.h +# automatically enable #define DISABLE_LIMITER_IN_DECODER in options.h, handling both /**/-comment and //-comment + - sed -i.bak -e "s/\/\*[[:space:]]*\(#define[[:space:]]*DISABLE_LIMITER_IN_DECODER\)[[:space:]]*\*\//\1/g" ./lib_com/options.h .get-commits-behind-count: &get-commits-behind-count - echo $CI_COMMIT_SHA diff --git a/apps/encoder.c b/apps/encoder.c index 4caa60803d8cad63471931608cc2cb2e719d65b9..84728c82c6dfaf0cf8d212438f22f0d18b40944d 100644 --- a/apps/encoder.c +++ b/apps/encoder.c @@ -190,6 +190,9 @@ int main( MasaFileReader *masaReader = NULL; IsmFileReader *ismReaders[IVAS_MAX_NUM_OBJECTS] = { NULL, NULL, NULL, NULL }; int16_t *pcmBuf = NULL; +#ifdef NONBE_FIX_1165_APPLY_LIMITER_ON_ENCODER_DMX + int32_t cnt_frames_limited; +#endif #ifdef DEBUGGING FILE *f_forcedModeProfile = NULL; #ifdef DEBUG_SBA @@ -792,7 +795,12 @@ int main( { fprintf( stdout, "\n\nEncoding of %d frames finished\n", frame ); } - +#ifdef NONBE_FIX_1165_APPLY_LIMITER_ON_ENCODER_DMX + if ( ( cnt_frames_limited = IVAS_ENC_GetCntFramesLimited( hIvasEnc ) ) > 0 ) + { + fprintf( stdout, "\nLimiter applied in %d frames.\n\n", cnt_frames_limited ); + } +#endif #ifdef DEBUGGING if ( ( noClipping = IVAS_ENC_GetNoCLipping( hIvasEnc, &maxOverload, &minOverload ) ) > 0 ) { diff --git a/lib_com/ivas_cnst.h b/lib_com/ivas_cnst.h index 105c0e8057fc08f9b1f63be8e0b0aa4d3fc8771d..299a21b2da8539e563445334c9c75345e70f82ea 100755 --- a/lib_com/ivas_cnst.h +++ b/lib_com/ivas_cnst.h @@ -1773,5 +1773,68 @@ typedef enum } STEREO_DMX_EVS_PRC; #endif + + +/*----------------------------------------------------------------------------------* + * 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 ) + +#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 ) + +#endif + /* clang-format on */ /* IVAS_CNST_H */ diff --git a/lib_com/ivas_limiter.c b/lib_com/ivas_limiter.c index 657e41683f3a7d94cc79d90eda645b82913e6a09..1e20578d6c4e3717b6ab2586a719dcb3150e77c0 100644 --- a/lib_com/ivas_limiter.c +++ b/lib_com/ivas_limiter.c @@ -170,6 +170,16 @@ void ivas_limiter_close( } +#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( +#else /*-------------------------------------------------------------------* * ivas_limiter_dec() * @@ -178,6 +188,7 @@ void ivas_limiter_close( *-------------------------------------------------------------------*/ void ivas_limiter_dec( +#endif 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 */ diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index c8d1a8169a17a7293d5a425a0a87e9059c02ef68..3b6b47126256ee5b37285745a2eebd1db33f3188 100755 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -5374,6 +5374,14 @@ 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 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 */ @@ -5865,6 +5873,14 @@ void ivas_omasa_modify_masa_energy_ratios( float masa_to_total_energy_ratio[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_MAXIMUM_CODING_SUBBANDS] ); +#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 /*----------------------------------------------------------------------------------* * TD Binaural Object renderer @@ -5992,7 +6008,11 @@ void ivas_limiter_close( IVAS_LIMITER_HANDLE* phLimiter /* i/o: pointer to limiter handle, can be NULL */ ); +#ifdef NONBE_FIX_1165_APPLY_LIMITER_ON_ENCODER_DMX +void ivas_limiter_apply +#else void ivas_limiter_dec +#endif ( IVAS_LIMITER_HANDLE hLimiter, /* i/o: limiter struct handle */ float *output[MAX_OUTPUT_CHANNELS], /* i/o: input/output buffer */ diff --git a/lib_com/ivas_rom_com.c b/lib_com/ivas_rom_com.c index 5f81d801f7672a0afadac4453627adf8995636e0..949fc58602158d4b9cf589ea4a617e2ffd4c352c 100644 --- a/lib_com/ivas_rom_com.c +++ b/lib_com/ivas_rom_com.c @@ -1831,18 +1831,33 @@ const int16_t Param_MC_index[MAX_CICP_CHANNELS] = 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 }; +#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) +#endif + const float ivas_param_mc_dmx_fac_CICP6_2tc[12] = { 1.0f, 0.0f, INV_SQRT2, INV_SQRT2, 1.0f, 0.0f, /*Lt*/ 0.0f, 1.0f, INV_SQRT2, INV_SQRT2, 0.0f, 1.0f /*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) +#endif + const float ivas_param_mc_dmx_fac_CICP12_2tc[16] = { 1.0f, 0.0f, INV_SQRT2, INV_SQRT2, 1.0f, 0.0f, 1.0f, 0.0f, /*Lt*/ 0.0f, 1.0f, INV_SQRT2, INV_SQRT2, 0.0f, 1.0f, 0.0f, 1.0f /*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) +#endif + const float ivas_param_mc_dmx_fac_CICP12_3tc[24] = { 1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, /*Lt*/ @@ -1850,11 +1865,22 @@ const float ivas_param_mc_dmx_fac_CICP12_3tc[24] = 0.0f, 0.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f /*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) +#endif + const float ivas_param_mc_dmx_fac_CICP14_2tc[16] = { 1.0f, 0.0f, INV_SQRT2, INV_SQRT2, 1.0f, 0.0f, 1.0f, 0.0f, /*Lt*/ 0.0f, 1.0f, INV_SQRT2, INV_SQRT2, 0.0f, 1.0f, 0.0f, 1.0f /*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) +#endif + const float ivas_param_mc_dmx_fac_CICP14_3tc[24] = { 1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, /*Lt*/ @@ -1862,6 +1888,11 @@ const float ivas_param_mc_dmx_fac_CICP14_3tc[24] = 0.0f, 0.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, /*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) +#endif + const float ivas_param_mc_dmx_fac_CICP16_3tc[30] = { 1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, /*Lt*/ @@ -1869,6 +1900,11 @@ const float ivas_param_mc_dmx_fac_CICP16_3tc[30] = 0.0f, 0.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f /*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) +#endif + const float ivas_param_mc_dmx_fac_CICP19_3tc[36] = { 1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, /*Lt*/ @@ -2139,7 +2175,13 @@ const PARAM_MC_CONF ivas_param_mc_conf[PARAM_MC_NUM_CONFIGS] = &ivas_param_mc_ild_mapping_CICP6_2tc, &ivas_param_mc_icc_mapping_CICP6_2tc, &ivas_param_mc_dmx_fac_CICP6_2tc[0], +#ifdef NONBE_FIX_1165_STATIC_SCAL_PARAMMC + &ivas_param_mc_ild_fac_CICP6_2tc[0], + ivas_param_mc_dmx_scal_fac_CICP6_2tc_static, + ivas_param_mc_dmx_scal_fac_CICP6_2tc_static_inv +#else &ivas_param_mc_ild_fac_CICP6_2tc[0] +#endif }, /* CICP6 64000 */ { @@ -2149,8 +2191,14 @@ 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_dmx_fac_CICP6_2tc[0], + &ivas_param_mc_dmx_fac_CICP6_2tc[0], +#ifdef NONBE_FIX_1165_STATIC_SCAL_PARAMMC + &ivas_param_mc_ild_fac_CICP6_2tc[0], + ivas_param_mc_dmx_scal_fac_CICP6_2tc_static, + ivas_param_mc_dmx_scal_fac_CICP6_2tc_static_inv +#else &ivas_param_mc_ild_fac_CICP6_2tc[0] +#endif }, /* CICP6 80000 */ { @@ -2160,8 +2208,14 @@ 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, - &ivas_param_mc_dmx_fac_CICP6_2tc[0], + &ivas_param_mc_dmx_fac_CICP6_2tc[0], +#ifdef NONBE_FIX_1165_STATIC_SCAL_PARAMMC + &ivas_param_mc_ild_fac_CICP6_2tc[0], + ivas_param_mc_dmx_scal_fac_CICP6_2tc_static, + ivas_param_mc_dmx_scal_fac_CICP6_2tc_static_inv +#else &ivas_param_mc_ild_fac_CICP6_2tc[0] +#endif }, /* CICP12 48000 */ { @@ -2171,8 +2225,14 @@ 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, - &ivas_param_mc_dmx_fac_CICP12_2tc[0], + &ivas_param_mc_dmx_fac_CICP12_2tc[0], +#ifdef NONBE_FIX_1165_STATIC_SCAL_PARAMMC + &ivas_param_mc_ild_fac_CICP12_2tc[0], + ivas_param_mc_dmx_scal_fac_CICP12_2tc_static, + ivas_param_mc_dmx_scal_fac_CICP12_2tc_static_inv +#else &ivas_param_mc_ild_fac_CICP12_2tc[0] +#endif }, /* CICP12 64000 */ { @@ -2182,8 +2242,14 @@ 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, - &ivas_param_mc_dmx_fac_CICP12_2tc[0], + &ivas_param_mc_dmx_fac_CICP12_2tc[0], +#ifdef NONBE_FIX_1165_STATIC_SCAL_PARAMMC + &ivas_param_mc_ild_fac_CICP12_2tc[0], + ivas_param_mc_dmx_scal_fac_CICP12_2tc_static, + ivas_param_mc_dmx_scal_fac_CICP12_2tc_static_inv +#else &ivas_param_mc_ild_fac_CICP12_2tc[0] +#endif }, /* CICP12 80000 */ { @@ -2194,7 +2260,13 @@ const PARAM_MC_CONF ivas_param_mc_conf[PARAM_MC_NUM_CONFIGS] = &ivas_param_mc_ild_mapping_CICP12_2tc, &ivas_param_mc_icc_mapping_CICP12_2tc, &ivas_param_mc_dmx_fac_CICP12_2tc[0], +#ifdef NONBE_FIX_1165_STATIC_SCAL_PARAMMC + &ivas_param_mc_ild_fac_CICP12_2tc[0], + ivas_param_mc_dmx_scal_fac_CICP12_2tc_static, + ivas_param_mc_dmx_scal_fac_CICP12_2tc_static_inv +#else &ivas_param_mc_ild_fac_CICP12_2tc[0] +#endif }, /* CICP12 96000 */ { @@ -2204,8 +2276,14 @@ 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, - &ivas_param_mc_dmx_fac_CICP12_3tc[0], + &ivas_param_mc_dmx_fac_CICP12_3tc[0], +#ifdef NONBE_FIX_1165_STATIC_SCAL_PARAMMC + &ivas_param_mc_ild_fac_CICP12_3tc[0], + ivas_param_mc_dmx_scal_fac_CICP12_3tc_static, + ivas_param_mc_dmx_scal_fac_CICP12_3tc_static_inv +#else &ivas_param_mc_ild_fac_CICP12_3tc[0] +#endif }, /* CICP14 48000 */ { @@ -2215,8 +2293,14 @@ 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, - &ivas_param_mc_dmx_fac_CICP14_2tc[0], + &ivas_param_mc_dmx_fac_CICP14_2tc[0], +#ifdef NONBE_FIX_1165_STATIC_SCAL_PARAMMC + &ivas_param_mc_ild_fac_CICP14_2tc[0], + ivas_param_mc_dmx_scal_fac_CICP14_2tc_static, + ivas_param_mc_dmx_scal_fac_CICP14_2tc_static_inv +#else &ivas_param_mc_ild_fac_CICP14_2tc[0] +#endif }, /* CICP14 64000 */ { @@ -2226,8 +2310,14 @@ 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_dmx_fac_CICP14_2tc[0], + &ivas_param_mc_dmx_fac_CICP14_2tc[0], +#ifdef NONBE_FIX_1165_STATIC_SCAL_PARAMMC + &ivas_param_mc_ild_fac_CICP14_2tc[0], + ivas_param_mc_dmx_scal_fac_CICP14_2tc_static, + ivas_param_mc_dmx_scal_fac_CICP14_2tc_static_inv +#else &ivas_param_mc_ild_fac_CICP14_2tc[0] +#endif }, /* CICP14 80000 */ { @@ -2237,8 +2327,14 @@ 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, - &ivas_param_mc_dmx_fac_CICP14_2tc[0], + &ivas_param_mc_dmx_fac_CICP14_2tc[0], +#ifdef NONBE_FIX_1165_STATIC_SCAL_PARAMMC + &ivas_param_mc_ild_fac_CICP14_2tc[0], + ivas_param_mc_dmx_scal_fac_CICP14_2tc_static, + ivas_param_mc_dmx_scal_fac_CICP14_2tc_static_inv +#else &ivas_param_mc_ild_fac_CICP14_2tc[0] +#endif }, /* CICP14 96000 */ { @@ -2249,7 +2345,13 @@ const PARAM_MC_CONF ivas_param_mc_conf[PARAM_MC_NUM_CONFIGS] = &ivas_param_mc_ild_mapping_CICP14_3tc, &ivas_param_mc_icc_mapping_CICP14_3tc, &ivas_param_mc_dmx_fac_CICP14_3tc[0], +#ifdef NONBE_FIX_1165_STATIC_SCAL_PARAMMC + &ivas_param_mc_ild_fac_CICP14_3tc[0], + ivas_param_mc_dmx_scal_fac_CICP14_3tc_static, + ivas_param_mc_dmx_scal_fac_CICP14_3tc_static_inv +#else &ivas_param_mc_ild_fac_CICP14_3tc[0] +#endif }, /* CICP16 96000 */ { @@ -2259,8 +2361,14 @@ 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, - &ivas_param_mc_dmx_fac_CICP16_3tc[0], + &ivas_param_mc_dmx_fac_CICP16_3tc[0], +#ifdef NONBE_FIX_1165_STATIC_SCAL_PARAMMC + &ivas_param_mc_ild_fac_CICP16_3tc[0], + ivas_param_mc_dmx_scal_fac_CICP16_3tc_static, + ivas_param_mc_dmx_scal_fac_CICP16_3tc_static_inv +#else &ivas_param_mc_ild_fac_CICP16_3tc[0] +#endif }, /* CICP16 128000 */ { @@ -2270,8 +2378,14 @@ const PARAM_MC_CONF ivas_param_mc_conf[PARAM_MC_NUM_CONFIGS] = IVAS_128k, &ivas_param_mc_ild_mapping_CICP16_3tc, &ivas_param_mc_icc_mapping_CICP16_3tc, - &ivas_param_mc_dmx_fac_CICP16_3tc[0], + &ivas_param_mc_dmx_fac_CICP16_3tc[0], +#ifdef NONBE_FIX_1165_STATIC_SCAL_PARAMMC + &ivas_param_mc_ild_fac_CICP16_3tc[0], + ivas_param_mc_dmx_scal_fac_CICP16_3tc_static, + ivas_param_mc_dmx_scal_fac_CICP16_3tc_static_inv +#else &ivas_param_mc_ild_fac_CICP16_3tc[0] +#endif }, /* CICP19 128000 */ { @@ -2281,8 +2395,14 @@ 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, - &ivas_param_mc_dmx_fac_CICP19_3tc[0], + &ivas_param_mc_dmx_fac_CICP19_3tc[0], +#ifdef NONBE_FIX_1165_STATIC_SCAL_PARAMMC + &ivas_param_mc_ild_fac_CICP19_3tc[0], + ivas_param_mc_dmx_scal_fac_CICP19_3tc_static, + ivas_param_mc_dmx_scal_fac_CICP19_3tc_static_inv +#else &ivas_param_mc_ild_fac_CICP19_3tc[0] +#endif } }; diff --git a/lib_com/ivas_stat_com.h b/lib_com/ivas_stat_com.h index 594e30ff26c77055da92f6e6ec598c14384a7400..2901644b4504e7ec2191b5f82eee834bb430d682 100644 --- a/lib_com/ivas_stat_com.h +++ b/lib_com/ivas_stat_com.h @@ -587,6 +587,10 @@ typedef struct ivas_param_mc_conf_struct /* structure for ROM Table */ const PARAM_MC_ICC_MAPPING *icc_mapping_conf; const float *dmx_fac; const float *ild_factors; +#ifdef NONBE_FIX_1165_STATIC_SCAL_PARAMMC + float static_dmx_fac; + float static_dmx_fac_inv; +#endif } PARAM_MC_CONF; @@ -794,4 +798,27 @@ typedef struct ivas_param_ism_data_structure float last_cardioid_left[MAX_NUM_OBJECTS]; } PARAM_ISM_CONFIG_DATA, *PARAM_ISM_CONFIG_HANDLE; +#ifdef NONBE_FIX_1165_APPLY_LIMITER_ON_ENCODER_DMX + + +/*----------------------------------------------------------------------------------* + * Limiter structure + *----------------------------------------------------------------------------------*/ + +typedef struct +{ + int16_t max_num_channels; + int16_t num_channels; + float **channel_ptrs; + int32_t sampling_rate; + float gain; + float release_heuristic; + float attack_constant; + int16_t strong_saturation_count; + int32_t cnt_frames_limited; /* counter of frames in which the limiter is applied */ + +} IVAS_LIMITER, *IVAS_LIMITER_HANDLE; + +#endif + #endif /* IVAS_STAT_COM */ diff --git a/lib_com/options.h b/lib_com/options.h index 97feb76cc3594cedaec5a5b4c2785af11f948d66..1cf35af57f35d61ef36b5c52aeb110652355e081 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -133,7 +133,7 @@ /*#define DEBUG_AGC_ENCODER_CMD_OPTION*/ /* Ability to force enable or disable AGC behaviour in DIRAC/SPAR via command line option */ /*#define DEBUG_JBM_CMD_OPTION*/ /* ability for telling the decoder the frontend fetch size and to not delay compensate for bad frames at the beginning */ /*#define VARIABLE_SPEED_DECODING*/ /* variable speed decoding employing the JBM functioniality; move to DEBUGGING after build for disabled is fixed */ -/*#define DISABLE_LIMITER*/ /* disable the limiter */ +/*#define DISABLE_LIMITER_IN_DECODER*/ /* disable the limiter */ /*Split Rendering Debug switches*/ /*#define DBG_WAV_WRITER*/ /* add debugging function dbgwrite_wav() */ @@ -150,7 +150,7 @@ /* keep as part of options.h */ #define BASOP_NOGLOB /* Disable global symbols in BASOPs, Overflow/Carry in BASOPs disabled, additional BASOPs in case of Overflow */ -/*#define DISABLE_LIMITER */ /* test switch for testing BE between 5ms and 20ms rendering */ +/*#define DISABLE_LIMITER_IN_DECODER */ /* test switch for testing BE between 5ms and 20ms rendering */ /* ################## Start DEVELOPMENT switches ######################### */ @@ -182,12 +182,23 @@ + +#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 */ +#define NONBE_FIX_1174_MCMASA_LBR_LOOP_ERROR /* Nokia: Fix issue 1174 by removing the unnecessary inner loop causing problems. */ + #define NONBE_FIX_1176_OSBA_REVERB_JBM_ASAN_ERROR /* Ericsson: Issue 1176, fix in TDREND_firfilt for subframes shorter than the filter length */ #define NONBE_FIX_1197_OMASA_META_BUFFER /* Nokia: OMASA ISM_MASA_MODE_PARAM_ONE_OBJ history zero in rateswitching */ #define FIX_1139_REV_COLORATION_SHORT_T60 /* Nokia,FhG: Fix issue 1139, prevent sound coloration artefacts at very low reverberation times */ #define FIX_1206_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 ########################### */ /* ################## End DEVELOPMENT switches ######################### */ diff --git a/lib_com/tools.c b/lib_com/tools.c index b235d5d499d17299577b47a33f41da52aaa7e671..8fe66c6e9b3a2757b644b5d3dd9ae9d90dc832ce 100644 --- a/lib_com/tools.c +++ b/lib_com/tools.c @@ -389,7 +389,6 @@ uint32_t check_clipping( for ( i = 0; i < n; i++ ) { temp = x[i]; - if ( temp >= ( MAX16B_FLT + 0.5f ) ) { noClipping++; diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index 4cb5aac155ba8cd41a4e54518e2b2cbdabec47fa..fbbeb393d0057c99f9676079c92d9bfaf94e238f 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -308,6 +308,14 @@ ivas_error ivas_jbm_dec_tc( if ( st_ivas->ivas_format == MASA_FORMAT ) { +#ifdef NONBE_FIX_1165_STATIC_SCAL_OMASA + if ( st_ivas->hMasa->config.input_ivas_format == MASA_ISM_FORMAT ) + { + /* Revert scaling done to the downmix in the encoder */ + ivas_omasa_gain_umx( st_ivas, p_output, output_frame ); + } + +#endif ivas_masa_prerender( st_ivas, p_output, output_frame, nchan_remapped ); /* external output */ @@ -390,6 +398,11 @@ ivas_error ivas_jbm_dec_tc( hp20( p_output[n], output_frame, st_ivas->mem_hp20_out[n], output_Fs ); } +#ifdef NONBE_FIX_1165_STATIC_SCAL_OMASA + /* Revert scaling done to the downmix in the encoder */ + ivas_omasa_gain_umx( st_ivas, p_output, output_frame ); + +#endif if ( st_ivas->renderer_type == RENDERER_MONO_DOWNMIX ) { ivas_ism_mono_dmx( st_ivas, p_output, output_frame ); @@ -640,6 +653,14 @@ ivas_error ivas_jbm_dec_tc( hp20( p_output[n], output_frame, st_ivas->mem_hp20_out[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( p_output[n], st_ivas->hParamMC->static_dmx_fac, p_output[n], output_frame ); + } + +#endif /* Rendering */ if ( output_config == IVAS_AUDIO_CONFIG_MONO || output_config == IVAS_AUDIO_CONFIG_STEREO ) { @@ -676,6 +697,11 @@ ivas_error ivas_jbm_dec_tc( return error; } +#ifdef NONBE_FIX_1165_STATIC_SCAL_MCMASA + /* Revert scaling done to the downmix in the encoder */ + ivas_mcmasa_gain_umx( st_ivas, p_output, output_frame ); + +#endif /* Delay the separated channel to sync with CLDFB delay of the DirAC synthesis, and synthesize the LFE signal. */ if ( output_config == IVAS_AUDIO_CONFIG_5_1 || output_config == IVAS_AUDIO_CONFIG_7_1 || output_config == IVAS_AUDIO_CONFIG_5_1_4 || output_config == IVAS_AUDIO_CONFIG_7_1_4 || @@ -705,6 +731,11 @@ ivas_error ivas_jbm_dec_tc( return error; } } + +#ifdef NONBE_FIX_1165_STATIC_SCAL_MCMASA + /* Revert scaling done to the downmix in the encoder */ + ivas_mcmasa_gain_umx( st_ivas, p_output, output_frame ); +#endif } if ( st_ivas->sba_dirac_stereo_flag ) /* use the flag to trigger the DFT upmix */ @@ -1309,6 +1340,12 @@ ivas_error ivas_jbm_dec_render( else if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) { ivas_dirac_dec_binaural_render( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, nchan_remapped, p_output ); +#ifdef NONBE_FIX_1165_STATIC_SCAL_OSBA_PREREND + for ( n = 0; n < nchan_out; n++ ) + { + v_multc( p_output[n], 2.0f, p_output[n], *nSamplesRendered ); + } +#endif } else { @@ -1316,6 +1353,12 @@ ivas_error ivas_jbm_dec_render( { return error; } +#ifdef NONBE_FIX_1165_STATIC_SCAL_OSBA_PREREND + for ( n = 0; n < nchan_out; n++ ) + { + v_multc( p_output[n], 2.0f, p_output[n], *nSamplesRendered ); + } +#endif if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_EXTERNAL ) { @@ -1516,8 +1559,12 @@ ivas_error ivas_jbm_dec_render( { if ( st_ivas->ivas_format != MONO_FORMAT ) { -#ifndef DISABLE_LIMITER +#ifndef DISABLE_LIMITER_IN_DECODER +#ifdef NONBE_FIX_1165_APPLY_LIMITER_ON_ENCODER_DMX + ivas_limiter_apply( st_ivas->hLimiter, p_output, nchan_out, *nSamplesRendered, st_ivas->BER_detect ); +#else ivas_limiter_dec( st_ivas->hLimiter, p_output, nchan_out, *nSamplesRendered, st_ivas->BER_detect ); +#endif #endif } } @@ -1782,8 +1829,12 @@ ivas_error ivas_jbm_dec_flush_renderer( { if ( st_ivas->ivas_format != MONO_FORMAT ) { -#ifndef DISABLE_LIMITER +#ifndef DISABLE_LIMITER_IN_DECODER +#ifdef NONBE_FIX_1165_APPLY_LIMITER_ON_ENCODER_DMX + ivas_limiter_apply( st_ivas->hLimiter, p_output, st_ivas->hDecoderConfig->nchan_out, *nSamplesRendered, st_ivas->BER_detect ); +#else ivas_limiter_dec( st_ivas->hLimiter, p_output, st_ivas->hDecoderConfig->nchan_out, *nSamplesRendered, st_ivas->BER_detect ); +#endif #endif } } diff --git a/lib_dec/ivas_masa_dec.c b/lib_dec/ivas_masa_dec.c index 49ee7753f31733f486489d1b987cf0f86fe8ebec..1dfc2923e780c8ef93bd6d31dba94cb2500f31a2 100644 --- a/lib_dec/ivas_masa_dec.c +++ b/lib_dec/ivas_masa_dec.c @@ -468,6 +468,10 @@ ivas_error ivas_masa_decode( } else if ( !st->bfi && ivas_format == MASA_FORMAT && 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 */ + +#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 934fc6fac24e34dd8e54f9ef6cbf3fb46ec3b090..68d213a80f5a2aac954eec62f05b4e40c594698e 100644 --- a/lib_dec/ivas_mc_param_dec.c +++ b/lib_dec/ivas_mc_param_dec.c @@ -312,6 +312,9 @@ ivas_error ivas_param_mc_dec_open( return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Parametric MC\n" ) ); } mvr2r( ivas_param_mc_conf[config_index].dmx_fac, hParamMC->proto_matrix_int, nchan_transport * nchan_out_transport ); +#ifdef NONBE_FIX_1165_STATIC_SCAL_PARAMMC + hParamMC->static_dmx_fac = ivas_param_mc_conf[config_index].static_dmx_fac; +#endif if ( hParamMC->synthesis_conf == PARAM_MC_SYNTH_LS_CONV_COV || hParamMC->synthesis_conf == PARAM_MC_SYNTH_MONO_STEREO ) { @@ -763,6 +766,9 @@ ivas_error ivas_param_mc_dec_reconfig( return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Parametric MC\n" ) ); } mvr2r( ivas_param_mc_conf[config_index].dmx_fac, hParamMC->proto_matrix_int, nchan_transport * nchan_out_transport ); +#ifdef NONBE_FIX_1165_STATIC_SCAL_PARAMMC + hParamMC->static_dmx_fac = ivas_param_mc_conf[config_index].static_dmx_fac; +#endif } if ( hParamMC->synthesis_conf == PARAM_MC_SYNTH_LS_CONV_COV || hParamMC->synthesis_conf == PARAM_MC_SYNTH_MONO_STEREO ) diff --git a/lib_dec/ivas_mcmasa_dec.c b/lib_dec/ivas_mcmasa_dec.c index e66eb5d24d5217ad6bf0fe76d2fa48add11512e5..811a240900136e038dcea4ed14e4c9a1e46e6110 100755 --- a/lib_dec/ivas_mcmasa_dec.c +++ b/lib_dec/ivas_mcmasa_dec.c @@ -98,3 +98,90 @@ 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( + 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 */ +) +{ + float gain; + int16_t nchan_transport; + uint8_t separateChannelEnabled; + + nchan_transport = st_ivas->nchan_transport; + separateChannelEnabled = st_ivas->hOutSetup.separateChannelEnabled; + gain = 1.0f; + + if ( separateChannelEnabled ) + { + /* Separate channel gaining */ + v_multc( data_f[2], ivas_mcmasa_dmx_scal_fac_sep_chan_static, data_f[2], output_frame ); + + /* Downmix channels gaining */ + if ( st_ivas->transport_config == IVAS_AUDIO_CONFIG_5_1_4 ) + { + gain = ivas_mcmasa_dmx_scal_fac_CICP16_3tc_static; + } + else if ( st_ivas->transport_config == IVAS_AUDIO_CONFIG_7_1_4 ) + { + gain = ivas_mcmasa_dmx_scal_fac_CICP19_3tc_static; + } + + v_multc( data_f[0], gain, data_f[0], output_frame ); + v_multc( data_f[1], gain, data_f[1], output_frame ); + } + else + { + if ( nchan_transport == 2 ) + { + if ( st_ivas->transport_config == IVAS_AUDIO_CONFIG_5_1_4 ) + { + gain = ivas_mcmasa_dmx_scal_fac_CICP16_2tc_static; + } + else if ( st_ivas->transport_config == IVAS_AUDIO_CONFIG_7_1_4 ) + { + gain = ivas_mcmasa_dmx_scal_fac_CICP19_2tc_static; + } + + v_multc( data_f[0], gain, data_f[0], output_frame ); + v_multc( data_f[1], gain, data_f[1], output_frame ); + } + else + { + if ( st_ivas->transport_config == IVAS_AUDIO_CONFIG_5_1 ) + { + gain = ivas_mcmasa_dmx_scal_fac_CICP6_1tc_static; + } + else if ( st_ivas->transport_config == IVAS_AUDIO_CONFIG_7_1 ) + { + gain = ivas_mcmasa_dmx_scal_fac_CICP12_1tc_static; + } + else if ( st_ivas->transport_config == IVAS_AUDIO_CONFIG_5_1_2 ) + { + gain = ivas_mcmasa_dmx_scal_fac_CICP14_1tc_static; + } + else if ( st_ivas->transport_config == IVAS_AUDIO_CONFIG_5_1_4 ) + { + gain = ivas_mcmasa_dmx_scal_fac_CICP16_1tc_static; + } + else if ( st_ivas->transport_config == IVAS_AUDIO_CONFIG_7_1_4 ) + { + gain = ivas_mcmasa_dmx_scal_fac_CICP19_1tc_static; + } + + v_multc( data_f[0], gain, data_f[0], output_frame ); + } + } + + return; +} +#endif diff --git a/lib_dec/ivas_omasa_dec.c b/lib_dec/ivas_omasa_dec.c index 243b5cf44a6dbd9a51adb0967fb979a2ea8fb144..880156c6cee4055f0359141f18e4eb8deade4cda 100644 --- a/lib_dec/ivas_omasa_dec.c +++ b/lib_dec/ivas_omasa_dec.c @@ -1420,3 +1420,72 @@ void ivas_omasa_render_objects_from_mix( 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( + 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 */ +) +{ + float gain; + int16_t nchan_ism; + + nchan_ism = st_ivas->nchan_ism; + gain = 1.0f; + + if ( st_ivas->ivas_format == MASA_FORMAT && st_ivas->hMasa->config.input_ivas_format == MASA_ISM_FORMAT ) + { + /* Full downmix mode */ + if ( nchan_ism == 1 ) + { + gain = ivas_omasa_dmx_scal_fac_2ch_static; + } + else if ( nchan_ism == 2 ) + { + gain = ivas_omasa_dmx_scal_fac_3ch_static; + } + else if ( nchan_ism == 3 ) + { + gain = ivas_omasa_dmx_scal_fac_4ch_static; + } + else if ( nchan_ism == 4 ) + { + gain = ivas_omasa_dmx_scal_fac_5ch_static; + } + } + else if ( st_ivas->ivas_format == MASA_ISM_FORMAT && ( st_ivas->ism_mode == ISM_MASA_MODE_MASA_ONE_OBJ || st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ ) ) + { + /* One separated object + downmix mode */ + if ( nchan_ism == 2 ) + { + gain = ivas_omasa_dmx_scal_fac_2ch_static; + } + else if ( nchan_ism == 3 ) + { + gain = ivas_omasa_dmx_scal_fac_3ch_static; + } + else if ( nchan_ism == 4 ) + { + gain = ivas_omasa_dmx_scal_fac_4ch_static; + } + } + else + { + /* Skip gain */ + return; + } + + v_multc( data_f[0], gain, data_f[0], output_frame ); + v_multc( data_f[1], gain, data_f[1], output_frame ); + + return; +} +#endif diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index 2515b1cc99cd3610a05685511cb51fd1e86fe1cf..c69c5acaf712cb524dd352e954ffcf87042fb98a 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -534,6 +534,9 @@ typedef struct ivas_param_mc_dec_data_structure int16_t max_param_band_abs_cov; float *ls_conv_dmx_matrix; float *proto_matrix_int; +#ifdef NONBE_FIX_1165_STATIC_SCAL_PARAMMC + float static_dmx_fac; +#endif /*sub-modules*/ HANDLE_DIRAC_DECORR_PARAMS h_freq_domain_decorr_ap_params; diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 5611f70fba6c62b04d45ea532e1594f3f84d20ac..0f425c4b25a7ec53219ad96d25bcf22f4cdd6b74 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -2112,13 +2112,21 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream( { if ( st_ivas->hDecoderConfig->render_framesize == IVAS_RENDER_FRAMESIZE_5MS ) { -#ifndef DISABLE_LIMITER +#ifndef DISABLE_LIMITER_IN_DECODER +#ifdef NONBE_FIX_1165_APPLY_LIMITER_ON_ENCODER_DMX + ivas_limiter_apply( st_ivas->hLimiter, pOutput, st_ivas->hDecoderConfig->nchan_out, numSamplesPerChannelToDecode, st_ivas->BER_detect ); +#else ivas_limiter_dec( st_ivas->hLimiter, pOutput, st_ivas->hDecoderConfig->nchan_out, numSamplesPerChannelToDecode, st_ivas->BER_detect ); +#endif #endif } else { +#ifdef NONBE_FIX_1165_APPLY_LIMITER_ON_ENCODER_DMX + ivas_limiter_apply( st_ivas->hLimiter, pOutput, st_ivas->hDecoderConfig->nchan_out, numSamplesPerChannelToDecode, st_ivas->BER_detect ); +#else ivas_limiter_dec( st_ivas->hLimiter, pOutput, st_ivas->hDecoderConfig->nchan_out, numSamplesPerChannelToDecode, st_ivas->BER_detect ); +#endif } #ifdef DEBUGGING diff --git a/lib_enc/ivas_cpe_enc.c b/lib_enc/ivas_cpe_enc.c index 292cbd6a5fc4d2738e8d0b94c3c76600dffb7fd9..661dd5756eab088ac9fd8369f21f8e6ecd1f096f 100644 --- a/lib_enc/ivas_cpe_enc.c +++ b/lib_enc/ivas_cpe_enc.c @@ -473,7 +473,6 @@ ivas_error ivas_cpe_enc( { #ifdef DEBUGGING st_ivas->noClipping += check_clipping( hCPE->hCoreCoder[n]->input, input_frame, &st_ivas->maxOverload, &st_ivas->minOverload ); - #endif error = pre_proc_front_ivas( NULL, hCPE, hCPE->element_brate, nb_bits_metadata, input_frame, n, old_inp_12k8[n], old_inp_16k[n], &ener[n], &relE[n], A[n], Aw[n], epsP[n], lsp_new[n], lsp_mid[n], &vad_hover_flag[n], &attack_flag[n], diff --git a/lib_enc/ivas_enc.c b/lib_enc/ivas_enc.c index 5ddcf9a506727f7d37ba32b00a4c56c0dd393e91..1583dd4c33d6d63dd82178946a572736f1351fc6 100644 --- a/lib_enc/ivas_enc.c +++ b/lib_enc/ivas_enc.c @@ -64,6 +64,7 @@ ivas_error ivas_enc( float *data_f[MAX_INPUT_CHANNELS + MAX_NUM_OBJECTS]; int32_t ivas_total_brate; ivas_error error; + error = IVAS_ERR_OK; push_wmops( "ivas_enc" ); @@ -194,6 +195,11 @@ ivas_error ivas_enc( /* Stereo DMX generation */ ivas_param_ism_stereo_dmx( st_ivas, data_f, input_frame ); +#ifdef NONBE_FIX_1165_APPLY_LIMITER_ON_ENCODER_DMX + + /* Apply limiter on downmix */ + ivas_limiter_apply( st_ivas->hLimiter, data_f, MAX_PARAM_ISM_WAVE, input_frame, 0 ); +#endif /* Core coding of Stereo DMX */ if ( ( error = ivas_ism_enc( st_ivas, data_f, input_frame, nb_bits_metadata, 0 ) ) != IVAS_ERR_OK ) @@ -247,6 +253,11 @@ ivas_error ivas_enc( if ( ivas_format == SBA_FORMAT ) { ivas_sba_getTCs( data_f, st_ivas, input_frame ); +#ifdef NONBE_FIX_1165_APPLY_LIMITER_ON_ENCODER_DMX + + /* Apply limiter on transport channels */ + ivas_limiter_apply( st_ivas->hLimiter, data_f, st_ivas->nchan_transport, input_frame, 0 ); +#endif } /* core-coding of transport channels */ @@ -305,6 +316,11 @@ ivas_error ivas_enc( { /* Estimate MASA parameters for the objects */ ivas_omasa_enc( st_ivas->hOMasa, st_ivas->hMasa, st_ivas->hIsmMetaData, data_f, input_frame, st_ivas->nchan_transport, hEncoderConfig->nchan_ism, st_ivas->ism_mode, data_separated_object, &idx_separated_object ); +#ifdef NONBE_FIX_1165_APPLY_LIMITER_ON_ENCODER_DMX + + /* Apply limiter on downmix */ + ivas_limiter_apply( st_ivas->hLimiter, &data_f[hEncoderConfig->nchan_ism], CPE_CHANNELS, input_frame, 0 ); +#endif } /* Encode ISMs transport channels */ @@ -392,6 +408,11 @@ ivas_error ivas_enc( } hEncoderConfig->sba_planar = planar_sba_orig; + +#ifdef NONBE_FIX_1165_APPLY_LIMITER_ON_ENCODER_DMX + /* Apply limiter on SBA channels */ + ivas_limiter_apply( st_ivas->hLimiter, data_f, st_ivas->nchan_transport, input_frame, 0 ); +#endif } else { @@ -411,6 +432,11 @@ ivas_error ivas_enc( /* get SBA TCs */ ivas_sba_getTCs( &data_f[n], st_ivas, input_frame ); + +#ifdef NONBE_FIX_1165_APPLY_LIMITER_ON_ENCODER_DMX + /* Apply limiter on SBA channels */ + ivas_limiter_apply( st_ivas->hLimiter, &data_f[n], st_ivas->nchan_transport, input_frame, 0 ); +#endif } /* core-coding of transport channels */ @@ -482,6 +508,11 @@ ivas_error ivas_enc( /* encode Parametric MC parameters and write bitstream */ ivas_param_mc_enc( st_ivas, hMetaData, data_f, input_frame ); +#ifdef NONBE_FIX_1165_APPLY_LIMITER_ON_ENCODER_DMX + /* Apply limiter on downmix */ + ivas_limiter_apply( st_ivas->hLimiter, data_f, st_ivas->nchan_transport, input_frame, 0 ); +#endif + if ( st_ivas->nCPE == 1 ) /* Stereo DMX */ { if ( ( error = ivas_cpe_enc( st_ivas, 0, data_f[0], data_f[1], input_frame, hMetaData->nb_bits_tot ) ) != IVAS_ERR_OK ) @@ -512,6 +543,11 @@ ivas_error ivas_enc( return error; } +#ifdef NONBE_FIX_1165_APPLY_LIMITER_ON_ENCODER_DMX + /* Apply limiter on downmix */ + ivas_limiter_apply( st_ivas->hLimiter, data_f, st_ivas->hMcMasa->separateChannelEnabled ? st_ivas->nchan_transport + 1 : st_ivas->nchan_transport, input_frame, 0 ); +#endif + if ( st_ivas->hMcMasa->separateChannelEnabled ) { if ( ( error = ivas_sce_enc( st_ivas, 0, data_f[2], input_frame, 0 ) ) != IVAS_ERR_OK ) diff --git a/lib_enc/ivas_init_enc.c b/lib_enc/ivas_init_enc.c index 48a3286a4ed55b74249f954b260f6663d7e8b706..2787eb43a6ce61bb3f1de5c29ea4325728576e36 100644 --- a/lib_enc/ivas_init_enc.c +++ b/lib_enc/ivas_init_enc.c @@ -368,6 +368,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; } @@ -548,6 +553,13 @@ ivas_error ivas_init_encoder( { return error; } + +#ifdef NONBE_FIX_1165_APPLY_LIMITER_ON_ENCODER_DMX + if ( ( error = ivas_limiter_open( &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 ) @@ -625,6 +637,16 @@ 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( &st_ivas->hLimiter, HOA3_CHANNELS, st_ivas->hEncoderConfig->input_Fs ) ) != IVAS_ERR_OK ) + { + return error; + } + } +#endif } else if ( ivas_format == MASA_ISM_FORMAT ) { @@ -685,6 +707,13 @@ ivas_error ivas_init_encoder( { return error; } + +#ifdef NONBE_FIX_1165_APPLY_LIMITER_ON_ENCODER_DMX + if ( ( error = ivas_limiter_open( &st_ivas->hLimiter, CPE_CHANNELS, st_ivas->hEncoderConfig->input_Fs ) ) != IVAS_ERR_OK ) + { + return error; + } +#endif } else if ( ivas_format == SBA_ISM_FORMAT ) { @@ -770,6 +799,13 @@ ivas_error ivas_init_encoder( { return error; } + +#ifdef NONBE_FIX_1165_APPLY_LIMITER_ON_ENCODER_DMX + if ( ( error = ivas_limiter_open( &st_ivas->hLimiter, FOA_CHANNELS, st_ivas->hEncoderConfig->input_Fs ) ) != IVAS_ERR_OK ) + { + return error; + } +#endif } else if ( ivas_format == MC_FORMAT ) { @@ -856,6 +892,13 @@ ivas_error ivas_init_encoder( return error; } } + +#ifdef NONBE_FIX_1165_APPLY_LIMITER_ON_ENCODER_DMX + if ( ( error = ivas_limiter_open( &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 ) { @@ -897,6 +940,13 @@ ivas_error ivas_init_encoder( return error; } } + +#ifdef NONBE_FIX_1165_APPLY_LIMITER_ON_ENCODER_DMX + if ( ( error = ivas_limiter_open( &st_ivas->hLimiter, CPE_CHANNELS + 1, st_ivas->hEncoderConfig->input_Fs ) ) != IVAS_ERR_OK ) + { + return error; + } +#endif } } #ifdef DEBUGGING @@ -1129,6 +1179,11 @@ void ivas_destroy_enc( } } +#ifdef NONBE_FIX_1165_APPLY_LIMITER_ON_ENCODER_DMX + /* Limiter handle */ + ivas_limiter_close( &st_ivas->hLimiter ); +#endif + /* HP20 filter handles */ if ( st_ivas->mem_hp20_in != NULL ) { diff --git a/lib_enc/ivas_ism_enc.c b/lib_enc/ivas_ism_enc.c index c72431bd0bbba983877532e2df681f8215524060..bf24ce16a1773b4de9552d0001ce1f85c60e5078 100644 --- a/lib_enc/ivas_ism_enc.c +++ b/lib_enc/ivas_ism_enc.c @@ -174,7 +174,6 @@ ivas_error ivas_ism_enc( #ifdef DEBUGGING st_ivas->noClipping += check_clipping( hSCE->hCoreCoder[0]->input, input_frame, &st_ivas->maxOverload, &st_ivas->minOverload ); - #endif error = pre_proc_front_ivas( hSCE, NULL, hSCE->element_brate, nb_bits_metadata[sce_id], input_frame, 0, old_inp_12k8[sce_id][0], old_inp_16k[sce_id][0], &ener[sce_id][0], &relE[sce_id][0], A[sce_id][0], Aw[sce_id][0], epsP[sce_id][0], lsp_new[sce_id][0], lsp_mid[sce_id][0], &vad_hover_flag[sce_id][0], &attack_flag[sce_id][0], diff --git a/lib_enc/ivas_mc_param_enc.c b/lib_enc/ivas_mc_param_enc.c index 4269103937c89d936374d8d7ff67664b835e4e19..5247f7f8b56cbf3c708a6e2ab8ea30de6a4a4d47 100644 --- a/lib_enc/ivas_mc_param_enc.c +++ b/lib_enc/ivas_mc_param_enc.c @@ -136,6 +136,9 @@ ivas_error ivas_param_mc_enc_open( /* get dmx factors */ hParamMC->dmx_factors = ivas_param_mc_conf[config_index].dmx_fac; +#ifdef NONBE_FIX_1165_STATIC_SCAL_PARAMMC + hParamMC->static_dmx_fac_inv = ivas_param_mc_conf[config_index].static_dmx_fac_inv; +#endif /* set FB config. */ if ( ( error = ivas_fb_set_cfg( &fb_cfg, MC_FORMAT, nchan_inp, 0, 0, input_Fs, 0 ) ) != IVAS_ERR_OK ) @@ -260,6 +263,9 @@ ivas_error ivas_param_mc_enc_reconfig( /* get dmx factors */ hParamMC->dmx_factors = ivas_param_mc_conf[config_index].dmx_fac; +#ifdef NONBE_FIX_1165_STATIC_SCAL_PARAMMC + hParamMC->static_dmx_fac_inv = ivas_param_mc_conf[config_index].static_dmx_fac_inv; +#endif /* open/init parameter coding */ ivas_param_mc_metadata_open( mc_input_setup, ivas_total_brate, &hParamMC->hMetadataPMC ); @@ -538,6 +544,11 @@ static void ivas_param_mc_dmx( { ( *dmx_sample ) += data_f[idx[inp_ch]][i] * ( *( p_dmx_fac++ ) ); } +#ifdef NONBE_FIX_1165_STATIC_SCAL_PARAMMC + + /* Apply scaling gain to prevent clipping of downmix signals */ + *dmx_sample *= hParamMC->static_dmx_fac_inv; +#endif } } diff --git a/lib_enc/ivas_mcmasa_enc.c b/lib_enc/ivas_mcmasa_enc.c index a08dcea74d2b3320e378a3679107d2aa08e697c4..7b7ce1143a234391301bc5a793712ee1eea2a3e0 100644 --- a/lib_enc/ivas_mcmasa_enc.c +++ b/lib_enc/ivas_mcmasa_enc.c @@ -67,6 +67,10 @@ typedef struct static void ivas_mcmasa_dmx( MCMASA_ENC_HANDLE hMcMasa, float *data_f[], const int16_t input_frame, const int16_t nchan_transport, const int16_t nchan_inp ); +#ifdef NONBE_FIX_1165_STATIC_SCAL_MCMASA +static void ivas_mcmasa_gain_dmx( MCMASA_ENC_HANDLE hMcMasa, float *data_f[], const int16_t input_frame, const int16_t nchan_transport, const MC_LS_SETUP mc_ls_setup ); + +#endif static void compute_cov_mtx( float sr[MCMASA_MAX_ANA_CHANS][DIRAC_NO_FB_BANDS_MAX], float si[MCMASA_MAX_ANA_CHANS][DIRAC_NO_FB_BANDS_MAX], const int16_t freq, const int16_t N, CovarianceMatrix *COVls ); static void computeIntensityVector_enc( const int16_t *band_grouping, float Cldfb_RealBuffer[FOA_CHANNELS][DIRAC_NO_FB_BANDS_MAX], float Cldfb_ImagBuffer[FOA_CHANNELS][DIRAC_NO_FB_BANDS_MAX], const int16_t enc_param_start_band, const int16_t num_frequency_bands, float intensity_real[DIRAC_NUM_DIMS][MASA_FREQUENCY_BANDS] ); @@ -666,6 +670,11 @@ void ivas_mcmasa_enc( mvr2r( separatedChannelSignal, data_f[2], input_frame ); } +#ifdef NONBE_FIX_1165_STATIC_SCAL_MCMASA + /* Apply scaling gain to prevent clipping of downmix signals */ + ivas_mcmasa_gain_dmx( hMcMasa, data_f, 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; @@ -1427,6 +1436,85 @@ static void ivas_mcmasa_dmx( return; } +#ifdef NONBE_FIX_1165_STATIC_SCAL_MCMASA + +/* Gain downmix signals to prevent clipping */ +static void ivas_mcmasa_gain_dmx( + MCMASA_ENC_HANDLE hMcMasa, + float *data_f[], + const int16_t input_frame, + const int16_t nchan_transport, + const MC_LS_SETUP mc_ls_setup ) +{ + float gain; + + gain = 1.0f; + + if ( hMcMasa->separateChannelEnabled ) + { + /* Separate channel gaining */ + v_multc( data_f[2], ivas_mcmasa_dmx_scal_fac_sep_chan_static_inv, data_f[2], input_frame ); + + /* Downmix channels gaining */ + if ( mc_ls_setup == MC_LS_SETUP_5_1_4 ) + { + gain = ivas_mcmasa_dmx_scal_fac_CICP16_3tc_static_inv; + } + else if ( mc_ls_setup == MC_LS_SETUP_7_1_4 ) + { + gain = ivas_mcmasa_dmx_scal_fac_CICP19_3tc_static_inv; + } + + v_multc( data_f[0], gain, data_f[0], input_frame ); + v_multc( data_f[1], gain, data_f[1], input_frame ); + } + else + { + if ( nchan_transport == 2 ) + { + if ( mc_ls_setup == MC_LS_SETUP_5_1_4 ) + { + gain = ivas_mcmasa_dmx_scal_fac_CICP16_2tc_static_inv; + } + else if ( mc_ls_setup == MC_LS_SETUP_7_1_4 ) + { + gain = ivas_mcmasa_dmx_scal_fac_CICP19_2tc_static_inv; + } + + v_multc( data_f[0], gain, data_f[0], input_frame ); + v_multc( data_f[1], gain, data_f[1], input_frame ); + } + else + { + if ( mc_ls_setup == MC_LS_SETUP_5_1 ) + { + gain = ivas_mcmasa_dmx_scal_fac_CICP6_1tc_static_inv; + } + else if ( mc_ls_setup == MC_LS_SETUP_7_1 ) + { + gain = ivas_mcmasa_dmx_scal_fac_CICP12_1tc_static_inv; + } + else if ( mc_ls_setup == MC_LS_SETUP_5_1_2 ) + { + gain = ivas_mcmasa_dmx_scal_fac_CICP14_1tc_static_inv; + } + else if ( mc_ls_setup == MC_LS_SETUP_5_1_4 ) + { + gain = ivas_mcmasa_dmx_scal_fac_CICP16_1tc_static_inv; + } + else if ( mc_ls_setup == MC_LS_SETUP_7_1_4 ) + { + gain = ivas_mcmasa_dmx_scal_fac_CICP19_1tc_static_inv; + } + + v_multc( 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( diff --git a/lib_enc/ivas_omasa_enc.c b/lib_enc/ivas_omasa_enc.c index a8c793d8f9ba259d2c2d53f0d4027aa74b0083f9..b255767f122bb9174eb2d6714cf9dc7f64451ace 100644 --- a/lib_enc/ivas_omasa_enc.c +++ b/lib_enc/ivas_omasa_enc.c @@ -65,6 +65,11 @@ static void computeIntensityVector_enc( const int16_t *band_grouping, float Cldf static void computeReferencePower_omasa( const int16_t *band_grouping, float Cldfb_RealBuffer[FOA_CHANNELS][CLDFB_NO_CHANNELS_MAX], float Cldfb_ImagBuffer[FOA_CHANNELS][CLDFB_NO_CHANNELS_MAX], float *reference_power, const int16_t enc_param_start_band, const int16_t num_freq_bands ); +#ifdef NONBE_FIX_1165_STATIC_SCAL_OMASA +static void ivas_omasa_gain_dmx( ISM_MODE ism_mode, float *data_f[], const int16_t nchan_transport, const int16_t nchan_ism, const int16_t input_frame ); + +#endif + /*--------------------------------------------------------------------------* * ivas_omasa_enc_open() * @@ -629,6 +634,11 @@ void ivas_omasa_enc( /* Merge transport signals */ ivas_merge_masa_transports( data_out_f, &( data_in_f[nchan_ism] ), data_in_f, input_frame, nchan_transport ); +#ifdef NONBE_FIX_1165_STATIC_SCAL_OMASA + /* Apply scaling gain to prevent clipping of downmix signals */ + ivas_omasa_gain_dmx( ism_mode, data_in_f, nchan_transport, nchan_ism, input_frame ); + +#endif return; } @@ -1201,3 +1211,68 @@ static void computeReferencePower_omasa( return; } + +#ifdef NONBE_FIX_1165_STATIC_SCAL_OMASA +/* Gain downmix signals to prevent clipping */ +static void ivas_omasa_gain_dmx( + ISM_MODE ism_mode, + float *data_f[], + const int16_t nchan_transport, + const int16_t nchan_ism, + const int16_t input_frame ) +{ + int16_t ch; + float gain; + + gain = 1.0f; + + if ( ism_mode == ISM_MODE_NONE ) + { + /* Full downmix mode. */ + if ( nchan_ism == 1 ) + { + gain = ivas_omasa_dmx_scal_fac_2ch_static_inv; + } + else if ( nchan_ism == 2 ) + { + gain = ivas_omasa_dmx_scal_fac_3ch_static_inv; + } + else if ( nchan_ism == 3 ) + { + gain = ivas_omasa_dmx_scal_fac_4ch_static_inv; + } + else if ( nchan_ism == 4 ) + { + gain = ivas_omasa_dmx_scal_fac_5ch_static_inv; + } + } + else if ( ism_mode == ISM_MASA_MODE_MASA_ONE_OBJ || ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ ) + { + /* One separated object + downmix mode. */ + if ( nchan_ism == 2 ) + { + gain = ivas_omasa_dmx_scal_fac_2ch_static_inv; + } + else if ( nchan_ism == 3 ) + { + gain = ivas_omasa_dmx_scal_fac_3ch_static_inv; + } + else if ( nchan_ism == 4 ) + { + gain = ivas_omasa_dmx_scal_fac_4ch_static_inv; + } + } + else + { + /* Skip gain */ + return; + } + + for ( ch = 0; ch < nchan_transport; ch++ ) + { + v_multc( 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 b00396bfab311a4b0f18a85aae8efadb19bff3b5..d80ba381b128dc34ad38b839ff73081b27ac6cdf 100644 --- a/lib_enc/ivas_osba_enc.c +++ b/lib_enc/ivas_osba_enc.c @@ -72,7 +72,11 @@ static void ivas_merge_sba_transports( { for ( j = 0; j < input_frame; j++ ) { +#ifdef NONBE_FIX_1165_STATIC_SCAL_OSBA_PREREND + data_out_f[i][j] = 0.25f * ( data_in_f1[i][j] + data_in_f2[i][j] ); +#else data_out_f[i][j] = 0.5f * ( data_in_f1[i][j] + data_in_f2[i][j] ); +#endif } } diff --git a/lib_enc/ivas_sce_enc.c b/lib_enc/ivas_sce_enc.c index 257e8061953cd4b5d4e58d9cca2c7f6aac579660..fbfe5d4c5049851310aa346a305bf78572f84ff9 100644 --- a/lib_enc/ivas_sce_enc.c +++ b/lib_enc/ivas_sce_enc.c @@ -182,7 +182,6 @@ ivas_error ivas_sce_enc( #ifdef DEBUGGING st_ivas->noClipping += check_clipping( hSCE->hCoreCoder[0]->input, input_frame, &st_ivas->maxOverload, &st_ivas->minOverload ); - #endif error = pre_proc_front_ivas( hSCE, NULL, hSCE->element_brate, nb_bits_metadata, input_frame, 0, old_inp_12k8[0], old_inp_16k[0], &ener[0], &relE[0], A[0], Aw[0], epsP[0], lsp_new[0], lsp_mid[0], &vad_hover_flag[0], &attack_flag[0], diff --git a/lib_enc/ivas_stat_enc.h b/lib_enc/ivas_stat_enc.h index ad844b95d5252e8250c6ab645d2dc5e6dfba8c5d..31a61f0976aef6f00a5ce4524fd0c159168d674c 100644 --- a/lib_enc/ivas_stat_enc.h +++ b/lib_enc/ivas_stat_enc.h @@ -723,6 +723,9 @@ typedef struct ivas_param_mc_enc_data_structure IVAS_FB_MIXER_HANDLE hFbMixer; int16_t transient_detector_delay; const float *dmx_factors; +#ifdef NONBE_FIX_1165_STATIC_SCAL_PARAMMC + float static_dmx_fac_inv; +#endif /* Multichannel Specific Parameters */ IVAS_PARAM_MC_METADATA hMetadataPMC; @@ -1245,11 +1248,15 @@ typedef struct int16_t nSCE; /* number of total SCEs */ int16_t nCPE; /* number of total CPEs */ SCE_ENC_HANDLE hSCE[MAX_SCE]; /* SCE handles */ - CPE_ENC_HANDLE hCPE[MCT_MAX_BLOCKS]; /* CPE 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 */ - float maxOverload; /* Maximum overload value */ - float minOverload; /* Maximum overload value */ + float maxOverload; /* Maximum overload value */ + float minOverload; /* Minimum overload value */ #endif /* multichannel modules */ diff --git a/lib_enc/lib_enc.c b/lib_enc/lib_enc.c index acc1358db65f612d9e40e5df7a5be79cbbb4d949..ae8788efed69c09e9193ac361bd70e6b09df932d 100644 --- a/lib_enc/lib_enc.c +++ b/lib_enc/lib_enc.c @@ -2418,6 +2418,28 @@ static void init_encoder_config( return; } +#ifdef NONBE_FIX_1165_APPLY_LIMITER_ON_ENCODER_DMX + +/*---------------------------------------------------------------------* + * IVAS_ENC_GetCntFramesLimited() + * + * return number of frames where limiter is applied + *---------------------------------------------------------------------*/ + +int32_t IVAS_ENC_GetCntFramesLimited( + IVAS_ENC_HANDLE hIvasEnc /* i : IVAS encoder handle */ +) +{ + if ( hIvasEnc->st_ivas->hLimiter == NULL ) + { + return 0; + } + else + { + return hIvasEnc->st_ivas->hLimiter->cnt_frames_limited; + } +} +#endif #ifdef DEBUGGING /*---------------------------------------------------------------------* diff --git a/lib_enc/lib_enc.h b/lib_enc/lib_enc.h index 7ece6666523f1320245369cd700ef2e732054fd4..6ec11d32c59f0d70671b77e5d468e9efda41d706 100644 --- a/lib_enc/lib_enc.h +++ b/lib_enc/lib_enc.h @@ -383,6 +383,12 @@ void IVAS_ENC_PrintDisclaimer( void ); +#ifdef NONBE_FIX_1165_APPLY_LIMITER_ON_ENCODER_DMX +int32_t IVAS_ENC_GetCntFramesLimited( + IVAS_ENC_HANDLE hIvasEnc /* i : IVAS encoder handle */ +); +#endif + #ifdef DEBUGGING int32_t IVAS_ENC_GetNoCLipping( IVAS_ENC_HANDLE hIvasEnc, /* i : IVAS encoder handle */ diff --git a/lib_isar/lib_isar_post_rend.c b/lib_isar/lib_isar_post_rend.c index 38c25ff21ae4c65dbc75874e129e72d2a5066dcd..dcbb682ace5182c18b2a6ded14b057aacf79003f 100644 --- a/lib_isar/lib_isar_post_rend.c +++ b/lib_isar/lib_isar_post_rend.c @@ -259,7 +259,7 @@ static void accumulate2dArrayToBuffer( return; } -#ifndef DISABLE_LIMITER +#ifndef DISABLE_LIMITER_IN_DECODER /*-------------------------------------------------------------------* * limitRendererOutput() @@ -1680,7 +1680,7 @@ ivas_error ISAR_POST_REND_getSamples( return error; } -#ifndef DISABLE_LIMITER +#ifndef DISABLE_LIMITER_IN_DECODER #ifdef DEBUGGING hIvasRend->numClipping += #endif diff --git a/lib_rend/ivas_stat_rend.h b/lib_rend/ivas_stat_rend.h index f1d777699c83a970215f125106add0b5ba8d14d0..790740c8039f602db0ef7329d4b260b371cd0855 100644 --- a/lib_rend/ivas_stat_rend.h +++ b/lib_rend/ivas_stat_rend.h @@ -1312,6 +1312,7 @@ typedef struct ivas_hrtfs_statistics_struct } HRTFS_STATISTICS, *HRTFS_STATISTICS_HANDLE; +#ifndef NONBE_FIX_1165_APPLY_LIMITER_ON_ENCODER_DMX /*----------------------------------------------------------------------------------* * Limiter structure *----------------------------------------------------------------------------------*/ @@ -1332,7 +1333,7 @@ typedef struct } IVAS_LIMITER, *IVAS_LIMITER_HANDLE; - +#endif /*----------------------------------------------------------------------------------* * Loudspeaker Configuration Conversion structure *----------------------------------------------------------------------------------*/ diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index 1d16f0d2f07e04618b54a4ef6ae9be6eea4bfcae..5e969bb542854ffb3eebd29f7ceed67f0b566862 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -445,7 +445,7 @@ static void accumulate2dArrayToBuffer( * In-place saturation control for multichannel buffers with adaptive release time *-------------------------------------------------------------------*/ -#ifndef DISABLE_LIMITER +#ifndef DISABLE_LIMITER_IN_DECODER /*! r: number of clipped output samples */ static int32_t limitRendererOutput( IVAS_LIMITER_HANDLE hLimiter, /* i/o: limiter struct handle */ @@ -7562,7 +7562,7 @@ static ivas_error getSamplesInternal( if ( outAudio.config.is_cldfb == 0 ) { -#ifndef DISABLE_LIMITER +#ifndef DISABLE_LIMITER_IN_DECODER #ifdef DEBUGGING hIvasRend->numClipping += #endif diff --git a/scripts/prepare_delivery.sh b/scripts/prepare_delivery.sh index ac93a91043c90ec4b741136373aba7bfcf6486bb..2bb0711edff5512bbca2553c5f6b450d33eb184d 100755 --- a/scripts/prepare_delivery.sh +++ b/scripts/prepare_delivery.sh @@ -237,7 +237,7 @@ if coan_exists; then echo "-UDEBUG_AGC_ENCODER_CMD_OPTION" >> $COAN_LIST echo "-UDEBUG_JBM_CMD_OPTION" >> $COAN_LIST echo "-UVARIABLE_SPEED_DECODING" >> $COAN_LIST - echo "-UDISABLE_LIMITER" >> $COAN_LIST + echo "-UDISABLE_LIMITER_IN_DECODER" >> $COAN_LIST echo "-UDBG_WAV_WRITER" >> $COAN_LIST echo "-USPLIT_REND_WITH_HEAD_ROT_DEBUG" >> $COAN_LIST echo "-USPLIT_POSE_CORRECTION_DEBUG" >> $COAN_LIST