From b6028550b74bbdc4d07132429f9243883653bdf2 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Wed, 24 May 2023 09:24:26 +0200 Subject: [PATCH 1/3] fix floating point exception in noise est --- lib_com/options.h | 2 ++ lib_enc/nois_est.c | 15 +++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/lib_com/options.h b/lib_com/options.h index 0a9e37c191..a82400fe34 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -206,6 +206,8 @@ #define FIX_485_STATIC_BUFFERS /* FhG: move static buffers in DirAC parameter estimator to the DirAC struct */ +#define FIX_483 /* FhG: fix usse 483, division by zero in nois_est */ + /* ################## End DEVELOPMENT switches ######################### */ /* clang-format on */ diff --git a/lib_enc/nois_est.c b/lib_enc/nois_est.c index 50dab41028..bf506cd9db 100644 --- a/lib_enc/nois_est.c +++ b/lib_enc/nois_est.c @@ -378,6 +378,20 @@ void noise_est( { if ( st->hSpMusClas != NULL ) { +#ifdef FIX_483 + float E; + + E = mean( lf_E, 8 ); + if ( E < 1.0f ) + { + st->hSpMusClas->ener_RAT = 0.f; + } + else + { + st->hSpMusClas->ener_RAT = 10.0f * (float) log10( E ); + st->hSpMusClas->ener_RAT /= ( Etot + 0.01f ); + } +#else st->hSpMusClas->ener_RAT = 10.0f * (float) log10( mean( lf_E, 8 ) ); st->hSpMusClas->ener_RAT /= ( Etot + 0.01f ); @@ -385,6 +399,7 @@ void noise_est( { st->hSpMusClas->ener_RAT = 0.0f; } +#endif if ( st->hSpMusClas->ener_RAT > 1.0 ) { -- GitLab From cad2671fe80e5c180d48e97fac0c77fd818a0bd2 Mon Sep 17 00:00:00 2001 From: rhb Date: Wed, 24 May 2023 16:42:45 +0200 Subject: [PATCH 2/3] add FIX_483b which fixes use of uninitialized values in ivas_mct_core_enc --- lib_com/bitstream.c | 4 ++++ lib_com/options.h | 3 ++- lib_com/rom_com.c | 4 ++++ lib_enc/ivas_mct_core_enc.c | 9 +++++++++ lib_enc/ivas_stereo_mdct_stereo_enc.c | 4 ++++ 5 files changed, 23 insertions(+), 1 deletion(-) mode change 100644 => 100755 lib_com/bitstream.c mode change 100644 => 100755 lib_com/options.h mode change 100644 => 100755 lib_com/rom_com.c mode change 100644 => 100755 lib_enc/ivas_mct_core_enc.c mode change 100644 => 100755 lib_enc/ivas_stereo_mdct_stereo_enc.c diff --git a/lib_com/bitstream.c b/lib_com/bitstream.c old mode 100644 new mode 100755 index d2aae93ed4..95704e1a26 --- a/lib_com/bitstream.c +++ b/lib_com/bitstream.c @@ -772,7 +772,11 @@ int16_t get_ivas_max_num_indices_metadata( /* o } else if ( ivas_total_brate <= IVAS_256k ) { +#ifdef FIX_483b + return 1050; +#else return 1000; +#endif } else if ( ivas_total_brate <= IVAS_384k ) { diff --git a/lib_com/options.h b/lib_com/options.h old mode 100644 new mode 100755 index a82400fe34..fc88856516 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -206,7 +206,8 @@ #define FIX_485_STATIC_BUFFERS /* FhG: move static buffers in DirAC parameter estimator to the DirAC struct */ -#define FIX_483 /* FhG: fix usse 483, division by zero in nois_est */ +#define FIX_483 /* FhG: fix issue 483, division by zero in nois_est */ +#define FIX_483b /* FhG: fix issue 483, uninitialized values in ivas_mct_core_enc */ /* ################## End DEVELOPMENT switches ######################### */ /* clang-format on */ diff --git a/lib_com/rom_com.c b/lib_com/rom_com.c old mode 100644 new mode 100755 index e4b8ec9db9..3694cbf4be --- a/lib_com/rom_com.c +++ b/lib_com/rom_com.c @@ -21643,7 +21643,11 @@ const int16_t igf_tile_offset_table[IGF_BITRATE_UNKNOWN][2*IGF_MAX_TILES+1] = { { 4, 1, 0, 2, 40, 3, 80, 4, 140 }, /* 48000 FB (stereo TCX10) */ { 5, 2, 80, 4, 128, 6, 144, 7, 212, 9, 160 }, /* 64000 FB (stereo) */ { 3, 2, 212, 4, 280, 6, 200 }, /* 80000 FB (stereo) */ +#if 1 + { 2, 3, 200, 5, 240}, /* 96000 FB (stereo) */ +#else { 2, 3, 320, 5, 240}, /* 96000 FB (stereo) */ +#endif { 1, 2, 416} /*128000 FB (stereo) */ }; diff --git a/lib_enc/ivas_mct_core_enc.c b/lib_enc/ivas_mct_core_enc.c old mode 100644 new mode 100755 index 3bd05fca92..48a7abc42f --- a/lib_enc/ivas_mct_core_enc.c +++ b/lib_enc/ivas_mct_core_enc.c @@ -264,6 +264,11 @@ void ivas_mct_core_enc( sp_aud_decision0[i] = hCPE[cpe_id]->hCoreCoder[0]->sp_aud_decision0; +#ifdef FIX_483b + sts[i]->hTcxEnc->tns_ms_flag[0] = 0; + sts[i]->hTcxEnc->tns_ms_flag[1] = 0; +#endif + i++; } } @@ -339,7 +344,11 @@ void ivas_mct_core_enc( for ( n = 0; n < nSubframes; n++ ) { +#ifdef FIX_483b + if ( sts[ch]->hTcxEnc->tns_ms_flag[n] ) +#else if ( !sts[ch]->hTcxEnc->fUseTns[n] /*!sts[0]->fUseTns[n] && !sts[1]->fUseTns[n]*/ ) +#endif { /* power spectrum: MDCT^2 + MDST^2 */ for ( i = 0; i < L_subframeTCX; i++ ) diff --git a/lib_enc/ivas_stereo_mdct_stereo_enc.c b/lib_enc/ivas_stereo_mdct_stereo_enc.c old mode 100644 new mode 100755 index 4ef24de8a1..138c9436d6 --- a/lib_enc/ivas_stereo_mdct_stereo_enc.c +++ b/lib_enc/ivas_stereo_mdct_stereo_enc.c @@ -430,6 +430,10 @@ void stereo_coder_tcx( if ( !sts[0]->hTcxEnc->fUseTns[k] && !sts[1]->hTcxEnc->fUseTns[k] ) { +#ifdef FIX_483b + sts[0]->hTcxEnc->tns_ms_flag[k] = 1; + sts[1]->hTcxEnc->tns_ms_flag[k] = 1; +#endif ms_inv_mask_processing( hStereoMdct, sts, ms_mask, k, mdst_spectrum[0][k], mdst_spectrum[1][k], inv_mdst_spectrum[0][k], inv_mdst_spectrum[1][k], -1 ); ms_processing( hStereoMdct, sts, ms_mask, k, mdst_spectrum[0][k], mdst_spectrum[1][k], sfbConf->sfbCnt ); } -- GitLab From 9f00adc435f3a0576b6a503fc1871502671b3618 Mon Sep 17 00:00:00 2001 From: rhb Date: Wed, 24 May 2023 16:48:39 +0200 Subject: [PATCH 3/3] fix mistake of previous commit --- lib_com/rom_com.c | 4 ---- lib_enc/stat_enc.h | 4 ++++ 2 files changed, 4 insertions(+), 4 deletions(-) mode change 100644 => 100755 lib_enc/stat_enc.h diff --git a/lib_com/rom_com.c b/lib_com/rom_com.c index 3694cbf4be..e4b8ec9db9 100755 --- a/lib_com/rom_com.c +++ b/lib_com/rom_com.c @@ -21643,11 +21643,7 @@ const int16_t igf_tile_offset_table[IGF_BITRATE_UNKNOWN][2*IGF_MAX_TILES+1] = { { 4, 1, 0, 2, 40, 3, 80, 4, 140 }, /* 48000 FB (stereo TCX10) */ { 5, 2, 80, 4, 128, 6, 144, 7, 212, 9, 160 }, /* 64000 FB (stereo) */ { 3, 2, 212, 4, 280, 6, 200 }, /* 80000 FB (stereo) */ -#if 1 - { 2, 3, 200, 5, 240}, /* 96000 FB (stereo) */ -#else { 2, 3, 320, 5, 240}, /* 96000 FB (stereo) */ -#endif { 1, 2, 416} /*128000 FB (stereo) */ }; diff --git a/lib_enc/stat_enc.h b/lib_enc/stat_enc.h old mode 100644 new mode 100755 index 77c0ea3d34..1a5c893dbd --- a/lib_enc/stat_enc.h +++ b/lib_enc/stat_enc.h @@ -1121,6 +1121,10 @@ typedef struct tcx_enc_structure float *acelp_zir; float tcx_target_bits_fac; +#ifdef FIX_483b + int16_t tns_ms_flag[2]; +#endif + } TCX_ENC_DATA, *TCX_ENC_HANDLE; /*----------------------------------------------------------------------------------* * -- GitLab