diff --git a/lib_com/options.h b/lib_com/options.h index 62357fbd6be508a24c049f6fe41fd37776ed2c27..1e16c2160fce34a7a4a202a74856587f51158524 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -119,6 +119,7 @@ #define CODE_IMPROVEMENTS #define NONBE_1359_FIX_IVASREND_OMASA_BINAURAL_LOUDNESS /* Nokia: issue 1339: Apply scaling to the object-part of OMASA for binaural rendering in IVAS_rend. */ +#define NONBE_1362_FIX_OMASA_TO_MASA1_RENDERING /* Nokia: Fix OMASA to MASA1 rendering in IVAS_rend */ // object-editing feature porting #define TMP_FIX_SPLIT_REND // temporary fix to split-rendering (it follows the later state of the framework but it is needed now because of current test-conditions) diff --git a/lib_rend/ivas_omasa_ana_fx.c b/lib_rend/ivas_omasa_ana_fx.c index e441b3596d14dbe4d6108c0d815216e68fc8dfbe..310addb66fbb4efe0fdbcb863346f05a3de5c620 100644 --- a/lib_rend/ivas_omasa_ana_fx.c +++ b/lib_rend/ivas_omasa_ana_fx.c @@ -668,10 +668,80 @@ static void ivas_omasa_dmx_fx( } set16_fx( data_e, 0, 4 ); set16_fx( in_e, 0, 960 ); +#ifdef NONBE_1362_FIX_OMASA_TO_MASA1_RENDERING + max_e = 0; +#endif FOR( i = 0; i < nchan_ism; i++ ) { +#ifdef NONBE_1362_FIX_OMASA_TO_MASA1_RENDERING + IF( EQ_16( nchan_transport, 1 ) ) + { + FOR( j = 0; j < input_frame; j++ ) + { + data_out_f_fx[0][j] = L_add_sat( data_out_f_fx[0][j], data_in_f_fx[i][j] ); + move32(); + } + } + ELSE + { + azimuth_fx = extract_l( L_shr( ism_azimuth_fx[i], Q22 ) ); // Q0 + elevation_fx = extract_l( L_shr( ism_elevation_fx[i], Q22 ) ); // Q0 + + ivas_ism_get_stereo_gains_fx( azimuth_fx, elevation_fx, &gains_fx[0], &gains_fx[1] ); + + /* Downmix using the panning gains */ + FOR( j = 0; j < nchan_transport; j++ ) + { + test(); + IF( abs_s( gains_fx[j] ) > 0 || L_abs( prev_gains_fx[i][j] ) > 0 ) + { + FOR( k = 0; k < input_frame; k++ ) + { + g1_fx = interpolator_fx[k]; // Q15 + move16(); + scale = BASOP_Util_Add_MantExp( 16384, 1, negate( g1_fx ), 0, &g2_fx ); + + tmp1 = mult( g1_fx, gains_fx[j] ); + tmp2 = mult( g2_fx, (Word16) L_shr( prev_gains_fx[i][j], 16 ) ); // Q: ( ( ( 15 - scale ) + ( Q31 - Q16 ) ) - Q15 ) -> ( 15 - scale ) + scale = BASOP_Util_Add_MantExp( tmp1, 0, tmp2, scale, &tmp1 ); + L_tmp = data_in_f_fx[i][k]; // data_in_q + move32(); + tmp_e = sub( 31, *data_in_q ); + move16(); + + L_tmp = Mpy_32_16_1( L_tmp, tmp1 ); + scale = add( scale, tmp_e ); + + data_out_f_fx[j][k] = BASOP_Util_Add_Mant32Exp( data_out_f_fx[j][k], data_e[j], L_tmp, scale, &in_e[k] ); + move32(); + } + max_e = in_e[0]; + move16(); + FOR( l = 1; l < L_FRAME48k; l++ ) + { + IF( LT_16( max_e, in_e[l] ) ) + { + max_e = in_e[l]; + move16(); + } + } + + FOR( l = 0; l < L_FRAME48k; l++ ) + { + data_out_f_fx[j][l] = L_shr( data_out_f_fx[j][l], sub( max_e, in_e[l] ) ); // exponent: max_e, Q: ( 15 - max_e ) + move32(); + } + data_e[j] = max_e; + move16(); + } + + prev_gains_fx[i][j] = L_deposit_h( gains_fx[j] ); // Q31 + move32(); + } + } +#else azimuth_fx = extract_l( L_shr( ism_azimuth_fx[i], Q22 ) ); // Q0 elevation_fx = extract_l( L_shr( ism_elevation_fx[i], Q22 ) ); // Q0 @@ -727,13 +797,38 @@ static void ivas_omasa_dmx_fx( prev_gains_fx[i][j] = L_deposit_h( gains_fx[j] ); // Q31 move32(); } +#endif } +#ifdef NONBE_1362_FIX_OMASA_TO_MASA1_RENDERING + IF( NE_16( nchan_transport, 1 ) ) + { + max_e = data_e[0]; + move16(); + FOR( i = 1; i < nchan_transport; i++ ) + { + IF( LT_16( max_e, data_e[i] ) ) + { + max_e = data_e[i]; + move16(); + } + } + + FOR( i = 0; i < nchan_transport; i++ ) + { + FOR( j = 0; j < input_frame; j++ ) + { + data_out_f_fx[i][j] = L_shr( data_out_f_fx[i][j], sub( max_e, data_e[i] ) ); // exponent: max_e, Q: ( 15 - max_e ) + move32(); + } + } + } +#else max_e = data_e[0]; move16(); FOR( i = 1; i < nchan_transport; i++ ) { - if ( LT_16( max_e, data_e[i] ) ) + IF( LT_16( max_e, data_e[i] ) ) { max_e = data_e[i]; move16(); @@ -748,12 +843,21 @@ static void ivas_omasa_dmx_fx( move32(); } } +#endif FOR( i = 0; i < nchan_transport; i++ ) { Copy32( data_out_f_fx[i], data_in_f_fx[i], input_frame ); +#ifdef NONBE_1362_FIX_OMASA_TO_MASA1_RENDERING + IF( NE_16( nchan_transport, 1 ) ) + { + *data_in_q = sub( 31, max_e ); + move16(); + } +#else *data_in_q = sub( 31, max_e ); move16(); +#endif } return;