Resolve "USAN error in swb_tbe_enc.c: "-inf is outside the range of representable values of type 'short'" for OMASA encoding"
requested to merge 971-usan-error-in-swb_tbe_enc-c-inf-is-outside-the-range-of-representable-values-of-type-short-for into main
- Related issues: #971 (closed)
- Requested reviewers: @suhua
Reason why this change is needed
To solve the following UBSAN error:
lib_enc/swb_tbe_enc.c:2741:15: runtime error: -inf is outside the range of representable values of type 'short'
SUMMARY: UndefinedBehaviorSanitizer: float-cast-overflow lib_enc/swb_tbe_enc.c:2741:15 in
Description of the change
Prevent ratio
to be always higher than 1.0. This avoids log2(0.0) = -Inf
in the following statement
idxGain = (int16_t) ( log2_f( (float) ratio ) + 0.5f );
Affected operating points
BE modification. Affects all opearting points using FB TBE inside the core coder (SCE, ISMs, OMASA, OSBA). Affects EVS as well!
Edited by malenovsky