Skip to content

[Optimization] Calculation of preDelay in ivas_binaural_reverb_init() unnecessarily complex (division of constant enumerator / denominator)

Basic info

  • Float reference:
    • Encoder (float): n/a
    • Decoder (float): 2266639d
  • Fixed point:
    • Encoder (fixed): n/a
    • Decoder (fixed): dd4728fe

Bug description

This is a follow-up to #1831 (closed): The calculation of preDelay in ivas_binaural_reverb_init() is unnecessarily complex. More specifically, the following expression (floating point code)

preDelay = (int16_t) roundf( 48000.0f * roomAcoustics->acousticPreDelay / CLDFB_NO_CHANNELS_MAX );

is implemented using a 32 by 16 division in BASOP using constants for both, enumerator and denominator:

temp16 = BASOP_Util_Divide3216_Scale( 48000, CLDFB_NO_CHANNELS_MAX, &s );
temp16 = shl( temp16, s );                                            // Q0                                                                                                                                                                  
temp32 = Mult_32_16( roomAcoustics->acousticPreDelay_fx, temp16 );    // Q11                                                                                                                                                                 
preDelay = extract_l( L_shr( L_add( temp32, L_shl( 1, 10 ) ), 11 ) ); // Q0  

At least the BASOP_Util_Divide3216_Scale() should be avoided. Possibly, there is also a more elegant way of implementing the rounding function...

Edited by multrus