Skip to content

Resolve "USAN: value out of range for int16 in FEC_HQ_phase_ecu.c"

Reason why this change is needed

  • "USAN: value out of range for cast to int16_t from float(24bit mantissa) in FEC_HQ_phase_ecu.c"
  • Slightly incorrect extraction of fractional phase in C-Float, somewhat unsafe cast
  • Incorrect use of modulo "%" in extraction of fractional phase in C-Float L1095

Description of the change

ALT1 (active, proposed)

  • added cast to signed 32 bit from float(24 bit mantissa) in the phase dithering section
  • replaced WMC-costly "%32768" with L_and(0x000003ff ) in the regular peak evolution section
  • new cost approx. ~4 cycles

ALT2 (not active, not proposed)

  • range control(within a 16 bit signed integer) and rounding, not BE, but within 1 table index in the 1024 resolution sine/cosine table , i.e. a 1 corresponds to a phase change of (2*pi)/1024
  • This C-float solution costs about 6 cycles(with rounding), compared to the EVS-BASOP 3-4 cycles extraction,
  • not BE with previous IVAS code, not BE with EVS-MONO

misc:

  • the USAN reported error L1139 was occurring in a region where the phase was scrambled anyway. The undefined casting was not an actual problem in MSVC simulations
  • The inactive ALT2 the corrected extractions with rounding of the fraction for line 1095 improves precision and would guarantee that there is no overflow in the cast to int32_t (L1095), nor in the cast to int16_t(L1139)
  • the BE ALT1 is proposed due to avoiding the extra cycles and the added branching cost of checking for EVS_MONO in-loop

Affected operating points

All Phase ECU PLC conditions.

  1. (ALT1) BE

( 2. (ALT2) Produced bitstream is non-BE but it is fully backwards compatible for decoding. Decoded output may differ. )

Related to issue #1002 (closed)

Edited by Jonas Svedberg

Merge request reports

Loading