Loading lib_rend/ivas_dirac_rend_fx.c +42 −1 Original line number Diff line number Diff line Loading @@ -2801,13 +2801,54 @@ void protoSignalComputation2_fx( q_lr_hi_power = stereo_type_detect->q_right_hi_power; } q_lr_hi_power = sub( q_lr_hi_power, 1 ); /* = (q_lr_hi_power * 2) */ #ifdef FIX_BASOP_2442_MASA2TC_TO_MONO_AND_AMBI /* We need to use accurately EPSILON from float (1e-15) in correct Q format as it can * dominate the division in high bands when total_hi_power is low or zero. This leads to * decision differences between BASOP and float. Close enough value is 2^-50 which is * about 0.88e-15. */ Word32 denom_fx; Word16 q_denom; IF( GE_16( stereo_type_detect->q_total_hi_power, 81 ) ) { /* EPSILON dominates here so use it directly */ denom_fx = 0x40000000; /* 2^-50 in Q80 */ move32(); q_denom = 80; move16(); } ELSE { /* Add EPSILON in proper Q */ Word32 eps_fx = L_shr( 0x40000000, sub( 80, stereo_type_detect->q_total_hi_power ) ); /* EPSILON in Q(q_total_hi_power) */ denom_fx = L_add_sat( stereo_type_detect->total_hi_power_fx, eps_fx ); q_denom = stereo_type_detect->q_total_hi_power; } temp = BASOP_Util_Divide3232_Scale_newton( lr_hi_power_fx, denom_fx, &exp ); exp = sub( 31, add( sub( 31, exp ), sub( q_lr_hi_power, q_denom ) ) ); exp = s_min( exp, 0 ); /* 2*min(l,r) <= l+r so we can clamp ratio <= 1 */ #else temp = BASOP_Util_Divide3232_Scale_newton( lr_hi_power_fx, L_add( stereo_type_detect->total_hi_power_fx, EPSILON_FX ), &exp ); // Q=31-(exp+ stereo_type_detect->q_total_hi_power-q_lr_hi_power) exp = sub( 31, add( sub( 31, exp ), sub( q_lr_hi_power, stereo_type_detect->q_total_hi_power ) ) ); #endif temp = BASOP_Util_Log2( temp ); // q25 IF( NE_32( temp, MIN_32 ) ) { #ifdef FIX_BASOP_2442_MASA2TC_TO_MONO_AND_AMBI IF( LT_16( exp, -63 ) ) { temp = MIN_32; move32(); } ELSE { temp = Mpy_32_32( L_add( L_shl( exp, Q25 ), temp ), LOG10_2_Q31 ); // Q25 } #else temp = Mpy_32_32( L_add( L_shl( exp, Q25 ), temp ), LOG10_2_Q31 ); // Q25 #endif } // 20480 = 10 in Q11 lr_total_hi_ratio_fx = Mpy_32_16_1( temp, 20480 ); // Q21 Loading Loading
lib_rend/ivas_dirac_rend_fx.c +42 −1 Original line number Diff line number Diff line Loading @@ -2801,13 +2801,54 @@ void protoSignalComputation2_fx( q_lr_hi_power = stereo_type_detect->q_right_hi_power; } q_lr_hi_power = sub( q_lr_hi_power, 1 ); /* = (q_lr_hi_power * 2) */ #ifdef FIX_BASOP_2442_MASA2TC_TO_MONO_AND_AMBI /* We need to use accurately EPSILON from float (1e-15) in correct Q format as it can * dominate the division in high bands when total_hi_power is low or zero. This leads to * decision differences between BASOP and float. Close enough value is 2^-50 which is * about 0.88e-15. */ Word32 denom_fx; Word16 q_denom; IF( GE_16( stereo_type_detect->q_total_hi_power, 81 ) ) { /* EPSILON dominates here so use it directly */ denom_fx = 0x40000000; /* 2^-50 in Q80 */ move32(); q_denom = 80; move16(); } ELSE { /* Add EPSILON in proper Q */ Word32 eps_fx = L_shr( 0x40000000, sub( 80, stereo_type_detect->q_total_hi_power ) ); /* EPSILON in Q(q_total_hi_power) */ denom_fx = L_add_sat( stereo_type_detect->total_hi_power_fx, eps_fx ); q_denom = stereo_type_detect->q_total_hi_power; } temp = BASOP_Util_Divide3232_Scale_newton( lr_hi_power_fx, denom_fx, &exp ); exp = sub( 31, add( sub( 31, exp ), sub( q_lr_hi_power, q_denom ) ) ); exp = s_min( exp, 0 ); /* 2*min(l,r) <= l+r so we can clamp ratio <= 1 */ #else temp = BASOP_Util_Divide3232_Scale_newton( lr_hi_power_fx, L_add( stereo_type_detect->total_hi_power_fx, EPSILON_FX ), &exp ); // Q=31-(exp+ stereo_type_detect->q_total_hi_power-q_lr_hi_power) exp = sub( 31, add( sub( 31, exp ), sub( q_lr_hi_power, stereo_type_detect->q_total_hi_power ) ) ); #endif temp = BASOP_Util_Log2( temp ); // q25 IF( NE_32( temp, MIN_32 ) ) { #ifdef FIX_BASOP_2442_MASA2TC_TO_MONO_AND_AMBI IF( LT_16( exp, -63 ) ) { temp = MIN_32; move32(); } ELSE { temp = Mpy_32_32( L_add( L_shl( exp, Q25 ), temp ), LOG10_2_Q31 ); // Q25 } #else temp = Mpy_32_32( L_add( L_shl( exp, Q25 ), temp ), LOG10_2_Q31 ); // Q25 #endif } // 20480 = 10 in Q11 lr_total_hi_ratio_fx = Mpy_32_16_1( temp, 20480 ); // Q21 Loading