From 285af5d633d85d994b297c8a97551970294e0126 Mon Sep 17 00:00:00 2001 From: Tapani Pihlajakuja Date: Fri, 16 Jun 2023 17:52:38 +0300 Subject: [PATCH 1/2] Fix issue 564 by copying the relevant code JBM path --- lib_com/options.h | 1 + lib_dec/ivas_jbm_dec.c | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/lib_com/options.h b/lib_com/options.h index 7350f8ec6e..4564bdc51b 100755 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -158,6 +158,7 @@ #define FIX_557_CRASH_IN_ISM_DTX /* VA issue 557: fix crash in 1ISM 48 kbps DTX */ #define IGF_TUNING_96 /* FhG: Issue 546: slight tuning of IGF config used in 96 kbps stereo, 128 kbps SBA and others */ +#define FIX_564 /* Nokia: Issue 564: Fix gains in JBM path for SBA with parametric binaural renderer */ /* ################## End DEVELOPMENT switches ######################### */ /* clang-format on */ diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index 6871747db6..df9bb7476c 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -292,7 +292,20 @@ ivas_error ivas_jbm_dec_tc( } else if ( st_ivas->ivas_format == SBA_FORMAT && ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) ) { +#ifdef FIX_564 + float gain; + + if ( nchan_remapped == 1 ) + { + gain = 1.4454f; + } + else + { + gain = 1.3657f; + } +#else float gain = 0.8414f; /* Todo: Temporary gain for roughly matching the loudness. To be tuned later together with other outputs. Also, this is not inline with ivas_dec() */ +#endif for ( n = 0; n < nchan_remapped; n++ ) { -- GitLab From 6da038619bd1e4ae4efe65d5c281f986ac7b3774 Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 19 Jun 2023 08:55:05 +0200 Subject: [PATCH 2/2] introduce function ivas_dirac_dec_binaural_gain(); under FIX_564 --- lib_dec/ivas_dec.c | 5 +++ lib_dec/ivas_jbm_dec.c | 14 ++------ lib_rend/ivas_dirac_dec_binaural_functions.c | 35 ++++++++++++++++++++ lib_rend/ivas_prot_rend.h | 9 +++++ 4 files changed, 52 insertions(+), 11 deletions(-) diff --git a/lib_dec/ivas_dec.c b/lib_dec/ivas_dec.c index fd0bf5b530..02c74efa37 100644 --- a/lib_dec/ivas_dec.c +++ b/lib_dec/ivas_dec.c @@ -403,6 +403,10 @@ ivas_error ivas_dec( } else if ( st_ivas->ivas_format == SBA_FORMAT && ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) ) { +#ifdef FIX_564 + /* loudness correction */ + ivas_dirac_dec_binaural_gain( output, nchan_remapped, output_frame ); +#else float gain; if ( nchan_remapped == 1 ) @@ -418,6 +422,7 @@ ivas_error ivas_dec( { v_multc( output[n], gain, output[n], output_frame ); } +#endif } /* Loudspeakers, Ambisonics or Binaural rendering */ diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index df9bb7476c..0ee2615470 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -293,24 +293,16 @@ ivas_error ivas_jbm_dec_tc( else if ( st_ivas->ivas_format == SBA_FORMAT && ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) ) { #ifdef FIX_564 - float gain; - - if ( nchan_remapped == 1 ) - { - gain = 1.4454f; - } - else - { - gain = 1.3657f; - } + /* loudness correction */ + ivas_dirac_dec_binaural_gain( output, nchan_remapped, output_frame ); #else float gain = 0.8414f; /* Todo: Temporary gain for roughly matching the loudness. To be tuned later together with other outputs. Also, this is not inline with ivas_dec() */ -#endif for ( n = 0; n < nchan_remapped; n++ ) { v_multc( output[n], gain, output[n], output_frame ); } +#endif } } else if ( st_ivas->ivas_format == MC_FORMAT ) diff --git a/lib_rend/ivas_dirac_dec_binaural_functions.c b/lib_rend/ivas_dirac_dec_binaural_functions.c index 8db8d1a471..2b4643c8b4 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions.c @@ -408,6 +408,41 @@ void ivas_dirac_dec_binaural_render( } +#ifdef FIX_564 +/*------------------------------------------------------------------------- + * ivas_dirac_dec_binaural_gain() + * + * loudness correction for parametric binaural renderer + *------------------------------------------------------------------------*/ + +void ivas_dirac_dec_binaural_gain( + float output[][L_FRAME48k], /* i/o: synthesized core-coder transport channels/DirAC output */ + const int16_t nchan_remapped, /* i : num channels after remapping of TCs */ + const int16_t output_frame /* i : output frame length */ +) +{ + int16_t n; + float gain; + + if ( nchan_remapped == 1 ) + { + gain = 1.4454f; + } + else + { + gain = 1.3657f; + } + + for ( n = 0; n < nchan_remapped; n++ ) + { + v_multc( output[n], gain, output[n], output_frame ); + } + + return; +} +#endif + + /*------------------------------------------------------------------------- * ivas_dirac_dec_binaural() * diff --git a/lib_rend/ivas_prot_rend.h b/lib_rend/ivas_prot_rend.h index 4ea5cb4484..9594cf0b92 100644 --- a/lib_rend/ivas_prot_rend.h +++ b/lib_rend/ivas_prot_rend.h @@ -149,6 +149,15 @@ ivas_error ivas_sba_get_hoa_dec_matrix( const int16_t ambisonics_order /* i : Ambisonics order */ ); +#ifdef FIX_564 + +void ivas_dirac_dec_binaural_gain( + float output[][L_FRAME48k], /* i/o: synthesized core-coder transport channels/DirAC output */ + const int16_t nchan_remapped, /* i : num channels after remapping of TCs */ + const int16_t output_frame /* i : output frame length */ +); +#endif + void ivas_dirac_dec_binaural( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, /* i : combined orientation handle */ -- GitLab