Commit 9d9de3ba authored by multrus's avatar multrus
Browse files

address imprecision in ivas_get_dirac_sba_max_md_bits() with -funsafe-math-optimizations

parent 38c95a2f
Loading
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -385,7 +385,20 @@ void ivas_get_dirac_sba_max_md_bits(
        *metadata_max_bits = MAX16B; /* no limit */
    }

#ifdef FIX_FLOAT_1544_SBA_META_IMPRECISION_UNSAFE_MATH
    /*
       The expression ceilf( (float) *metadata_max_bits * nbands / 5 ) was converted to double precision because of issues with -funsafe-math-optimizations,
       where an imprecision of the division in combination with the ceilf()-operator could actually produce different results (+1) for *metadata_max_bits.
       Alternative ways to address this:
       1) Pick up the corresponding code from the BASOP codebase
       2) An expression which takes care of small imprecisions of the division, e.g., ceilf( ( (float) *metadata_max_bits * nbands / 5 ) - 0.1f )
          (minimum non-zero fractional part for X / 5 is 0.2 - substract half of this, to compensate for imprecisions; the ceilf() should still return the correct integer)
       For reasons of code-readability, the variant with double precision was chosen.
    */
    *metadata_max_bits = (int16_t) min( (float) MAX16B, ceilf( (double) *metadata_max_bits * nbands / 5 ) );
#else
    *metadata_max_bits = (int16_t) min( (float) MAX16B, ceilf( (float) *metadata_max_bits * nbands / 5 ) );
#endif
    *qmetadata_max_bit_req = QMETADATA_MAXBIT_REQ_SBA >> 1;

    return;
+1 −0
Original line number Diff line number Diff line
@@ -162,6 +162,7 @@
#define TMP_1342_WORKAROUND_DEC_FLUSH_BROKEN_IN_SR      /* FhG: Temporary workaround for incorrect implementation of decoder flush with split rendering */
#define NONBE_1122_KEEP_EVS_MODE_UNCHANGED              /* FhG: Disables fix for issue 1122 in EVS mode to keep BE tests green. This switch should be removed once the 1122 fix is added to EVS via a CR.  */
#define FIX_BASOP_2469_OBJ_EDIT_TD_REND_GAIN            /* Eri: Basop issue 2469: TD renderer gain has wrong Q. In float this is just a synch of the cleanup done in BASOP */
#define FIX_FLOAT_1544_SBA_META_IMPRECISION_UNSAFE_MATH /* FhG: float issue 1544: imprecision in ivas_get_dirac_sba_max_md_bits() with -funsafe-math-optimizations */

/* #################### End BE switches ################################## */