From 342430c51e3a9d5cd060ba9cfc04d73eeec1ead2 Mon Sep 17 00:00:00 2001 From: Adriana Vasilache Date: Tue, 17 Sep 2024 01:20:00 +0300 Subject: [PATCH 1/5] fix 853 fixed point --- lib_com/options.h | 2 +- lib_dec/ivas_masa_dec.c | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lib_com/options.h b/lib_com/options.h index 87f712150..424110028 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -191,7 +191,7 @@ #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 */ /* ################## End DEVELOPMENT switches ######################### */ /* clang-format on */ diff --git a/lib_dec/ivas_masa_dec.c b/lib_dec/ivas_masa_dec.c index 6903773ed..eb805a80c 100644 --- a/lib_dec/ivas_masa_dec.c +++ b/lib_dec/ivas_masa_dec.c @@ -5585,6 +5585,10 @@ static Word16 ivas_decode_masaism_metadata_fx( Word16 tmp_e; delta_phi = L_deposit_h( BASOP_Util_Divide1616_Scale( 180, no_phi_masa[bits_ism[obj] - 1][idx_el], &tmp_e ) ); delta_phi = L_shr( delta_phi, sub( 9, tmp_e ) ); /* to maintain Q22 */ +#ifdef FIX_853_DECODE_MASA_ISM_AZIMUTH_PREC + delta_phi = L_shr( delta_phi, 22 ); + delta_phi = L_shl( delta_phi, 22 ); +#endif IF( GT_32( L_sub( azimuth, hMasaIsmData->q_azimuth_old_fx[obj] ), delta_phi ) ) { azimuth = L_sub( azimuth, delta_phi ); -- GitLab From a7542956e41d112aa34c37569572f974d21661e9 Mon Sep 17 00:00:00 2001 From: Adriana Vasilache Date: Sat, 28 Sep 2024 16:48:44 +0300 Subject: [PATCH 2/5] fix 853 basop --- lib_dec/ivas_masa_dec.c | 36 ++++++++++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/lib_dec/ivas_masa_dec.c b/lib_dec/ivas_masa_dec.c index eb805a80c..f49c5556c 100644 --- a/lib_dec/ivas_masa_dec.c +++ b/lib_dec/ivas_masa_dec.c @@ -5522,7 +5522,12 @@ static Word16 ivas_decode_masaism_metadata_fx( Word16 nb_bits_read; Word32 delta_phi; // Q22 Word16 meta_write_index; +#if 1 + static FILE *pF = NULL; + if ( pF == NULL ) + pF = fopen( "./direction.txt", "w" ); +#endif nb_bits_read = *next_bit_pos; move16(); nbands = hQMetaData->q_direction->cfg.nbands; @@ -5585,19 +5590,46 @@ static Word16 ivas_decode_masaism_metadata_fx( Word16 tmp_e; delta_phi = L_deposit_h( BASOP_Util_Divide1616_Scale( 180, no_phi_masa[bits_ism[obj] - 1][idx_el], &tmp_e ) ); delta_phi = L_shr( delta_phi, sub( 9, tmp_e ) ); /* to maintain Q22 */ + #if 0 #ifdef FIX_853_DECODE_MASA_ISM_AZIMUTH_PREC - delta_phi = L_shr( delta_phi, 22 ); - delta_phi = L_shl( delta_phi, 22 ); + delta_phi = L_shr( delta_phi, 20 ); + delta_phi = L_shl( delta_phi, 20 ); +#endif + #endif +#if 1 + fprintf( pF, "azimuth = %4.2f delta_phi = %4.2f obj = %d \n", (float) azimuth / (float) 4194304, (float) delta_phi / (float) 4194304, obj ); #endif +#ifdef FIX_853_DECODE_MASA_ISM_AZIMUTH_PREC + Word32 tmp_32; + Word64 tmp_64; + tmp_32 = L_sub( azimuth, hMasaIsmData->q_azimuth_old_fx[obj] ); + tmp_64 = W_mult_32_16( tmp_32, no_phi_masa[bits_ism[obj] - 1][idx_el] ); + + + IF( GT_64( tmp_64, (DEGREE_360_Q_22 + 83886) ) ) /* >= 360 in Q22 + 0.02 in Q22, because there is an additional shift left in W_mult_32_16*/ +#else IF( GT_32( L_sub( azimuth, hMasaIsmData->q_azimuth_old_fx[obj] ), delta_phi ) ) +#endif { azimuth = L_sub( azimuth, delta_phi ); +#if 1 + fprintf( pF, "azimuth = %3.1f obj = %d 1 \n", (float) azimuth / (float) 4194304, obj ); +#endif } ELSE { +#ifdef FIX_853_DECODE_MASA_ISM_AZIMUTH_PREC + + IF( GT_64( -DEGREE_360_Q_22 - 83886, tmp_64 ) ) +#else if ( GT_32( L_sub( hMasaIsmData->q_azimuth_old_fx[obj], azimuth ), delta_phi ) ) +#endif { azimuth = L_add( azimuth, delta_phi ); +#if 1 + fprintf( pF, "azimuth = %3.1f obj = %d -1 \n", (float) azimuth / (float) 4194304, obj ); +#endif + } } } -- GitLab From e2801e12b3a46564a28f5996a1162eacb01be4ee Mon Sep 17 00:00:00 2001 From: Adriana Vasilache Date: Sat, 28 Sep 2024 17:53:05 +0300 Subject: [PATCH 3/5] fix 853 basop --- lib_com/ivas_cnst.h | 5 ++++- lib_dec/ivas_masa_dec.c | 24 ++++-------------------- 2 files changed, 8 insertions(+), 21 deletions(-) diff --git a/lib_com/ivas_cnst.h b/lib_com/ivas_cnst.h index 5fef65816..1356d695e 100644 --- a/lib_com/ivas_cnst.h +++ b/lib_com/ivas_cnst.h @@ -1353,7 +1353,10 @@ enum #define MASA_JBM_RINGBUFFER_FRAMES 3 - +#ifdef FIX_853_DECODE_MASA_ISM_AZIMUTH_PREC +#define TOLERANCE_360_Q22 1510033326 /* 360 in Q22 + 0.02 in Q22*/ +#define MINUS_TOLERANCE_360_Q22 -1510033326 /* - (360 in Q22 + 0.02 in Q22) */ +#endif typedef enum { MASA_STEREO_NOT_DEFINED, diff --git a/lib_dec/ivas_masa_dec.c b/lib_dec/ivas_masa_dec.c index f49c5556c..a1a7c5728 100644 --- a/lib_dec/ivas_masa_dec.c +++ b/lib_dec/ivas_masa_dec.c @@ -5590,46 +5590,30 @@ static Word16 ivas_decode_masaism_metadata_fx( Word16 tmp_e; delta_phi = L_deposit_h( BASOP_Util_Divide1616_Scale( 180, no_phi_masa[bits_ism[obj] - 1][idx_el], &tmp_e ) ); delta_phi = L_shr( delta_phi, sub( 9, tmp_e ) ); /* to maintain Q22 */ - #if 0 -#ifdef FIX_853_DECODE_MASA_ISM_AZIMUTH_PREC - delta_phi = L_shr( delta_phi, 20 ); - delta_phi = L_shl( delta_phi, 20 ); -#endif - #endif -#if 1 - fprintf( pF, "azimuth = %4.2f delta_phi = %4.2f obj = %d \n", (float) azimuth / (float) 4194304, (float) delta_phi / (float) 4194304, obj ); -#endif + #ifdef FIX_853_DECODE_MASA_ISM_AZIMUTH_PREC Word32 tmp_32; Word64 tmp_64; tmp_32 = L_sub( azimuth, hMasaIsmData->q_azimuth_old_fx[obj] ); tmp_64 = W_mult_32_16( tmp_32, no_phi_masa[bits_ism[obj] - 1][idx_el] ); - - IF( GT_64( tmp_64, (DEGREE_360_Q_22 + 83886) ) ) /* >= 360 in Q22 + 0.02 in Q22, because there is an additional shift left in W_mult_32_16*/ + IF( GT_64( tmp_64, TOLERANCE_360_Q22 ) ) /* >= 360 in Q22 (because there is an additional shift left in W_mult_32_16) + 0.02 in Q22 to counteract for precision loss, */ #else IF( GT_32( L_sub( azimuth, hMasaIsmData->q_azimuth_old_fx[obj] ), delta_phi ) ) #endif { azimuth = L_sub( azimuth, delta_phi ); -#if 1 - fprintf( pF, "azimuth = %3.1f obj = %d 1 \n", (float) azimuth / (float) 4194304, obj ); -#endif } ELSE { #ifdef FIX_853_DECODE_MASA_ISM_AZIMUTH_PREC - IF( GT_64( -DEGREE_360_Q_22 - 83886, tmp_64 ) ) + IF( GT_64( MINUS_TOLERANCE_360_Q22, tmp_64 ) ) #else if ( GT_32( L_sub( hMasaIsmData->q_azimuth_old_fx[obj], azimuth ), delta_phi ) ) #endif { - azimuth = L_add( azimuth, delta_phi ); -#if 1 - fprintf( pF, "azimuth = %3.1f obj = %d -1 \n", (float) azimuth / (float) 4194304, obj ); -#endif - + azimuth = L_add( azimuth, delta_phi ); } } } -- GitLab From f2c82000e89a82af976397b321c482382720f51f Mon Sep 17 00:00:00 2001 From: Adriana Vasilache Date: Sun, 29 Sep 2024 09:36:29 +0300 Subject: [PATCH 4/5] fix clang --- lib_dec/ivas_masa_dec.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/lib_dec/ivas_masa_dec.c b/lib_dec/ivas_masa_dec.c index a1a7c5728..eea31e559 100644 --- a/lib_dec/ivas_masa_dec.c +++ b/lib_dec/ivas_masa_dec.c @@ -5584,20 +5584,20 @@ static Word16 ivas_decode_masaism_metadata_fx( test(); test(); test(); - // if ( azimuth * hMasaIsmData->q_azimuth_old[obj] > 0 ) + /* if ( azimuth * hMasaIsmData->q_azimuth_old[obj] > 0 ) */ IF( ( ( azimuth > 0 ) && ( hMasaIsmData->q_azimuth_old_fx[obj] > 0 ) ) || ( ( azimuth < 0 ) && ( hMasaIsmData->q_azimuth_old_fx[obj] < 0 ) ) ) { Word16 tmp_e; delta_phi = L_deposit_h( BASOP_Util_Divide1616_Scale( 180, no_phi_masa[bits_ism[obj] - 1][idx_el], &tmp_e ) ); delta_phi = L_shr( delta_phi, sub( 9, tmp_e ) ); /* to maintain Q22 */ -#ifdef FIX_853_DECODE_MASA_ISM_AZIMUTH_PREC +#ifdef FIX_853_DECODE_MASA_ISM_AZIMUTH_PREC Word32 tmp_32; Word64 tmp_64; tmp_32 = L_sub( azimuth, hMasaIsmData->q_azimuth_old_fx[obj] ); tmp_64 = W_mult_32_16( tmp_32, no_phi_masa[bits_ism[obj] - 1][idx_el] ); - IF( GT_64( tmp_64, TOLERANCE_360_Q22 ) ) /* >= 360 in Q22 (because there is an additional shift left in W_mult_32_16) + 0.02 in Q22 to counteract for precision loss, */ + IF( GT_64( tmp_64, TOLERANCE_360_Q22 ) ) /* >= 360 in Q22 (because there is an additional shift left in W_mult_32_16) + 0.02 in Q22 to counteract for precision loss, */ #else IF( GT_32( L_sub( azimuth, hMasaIsmData->q_azimuth_old_fx[obj] ), delta_phi ) ) #endif @@ -5607,13 +5607,12 @@ static Word16 ivas_decode_masaism_metadata_fx( ELSE { #ifdef FIX_853_DECODE_MASA_ISM_AZIMUTH_PREC - IF( GT_64( MINUS_TOLERANCE_360_Q22, tmp_64 ) ) #else if ( GT_32( L_sub( hMasaIsmData->q_azimuth_old_fx[obj], azimuth ), delta_phi ) ) #endif { - azimuth = L_add( azimuth, delta_phi ); + azimuth = L_add( azimuth, delta_phi ); } } } -- GitLab From 0bbf2c7cd5140d12728312054c52bd515cdbb391 Mon Sep 17 00:00:00 2001 From: Adriana Vasilache Date: Tue, 8 Oct 2024 14:21:57 +0300 Subject: [PATCH 5/5] remove debug code from issue 853 --- lib_dec/ivas_masa_dec.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/lib_dec/ivas_masa_dec.c b/lib_dec/ivas_masa_dec.c index eea31e559..13e970f85 100644 --- a/lib_dec/ivas_masa_dec.c +++ b/lib_dec/ivas_masa_dec.c @@ -5522,12 +5522,7 @@ static Word16 ivas_decode_masaism_metadata_fx( Word16 nb_bits_read; Word32 delta_phi; // Q22 Word16 meta_write_index; -#if 1 - static FILE *pF = NULL; - if ( pF == NULL ) - pF = fopen( "./direction.txt", "w" ); -#endif nb_bits_read = *next_bit_pos; move16(); nbands = hQMetaData->q_direction->cfg.nbands; -- GitLab