diff --git a/lib_com/ivas_cnst.h b/lib_com/ivas_cnst.h index 5fef6581695d157454575cc93298568726f9aca1..1356d695eccdec5054deb00d227fd83d73bcaa42 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_com/options.h b/lib_com/options.h index 87f712150c1b4dcd6e7daf2882ca4b1766b21f43..424110028debf7da0327fdb2c4881abb181d2567 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 6903773ede2ee6d489ba6b159939602919b372a8..13e970f85fcc6e5ab670952c19be8a14b9b72195 100644 --- a/lib_dec/ivas_masa_dec.c +++ b/lib_dec/ivas_masa_dec.c @@ -5579,19 +5579,33 @@ 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 + 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, */ +#else IF( GT_32( L_sub( azimuth, hMasaIsmData->q_azimuth_old_fx[obj] ), delta_phi ) ) +#endif { azimuth = L_sub( azimuth, delta_phi ); } 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 ); }